From 1fd42472e2b1a2169d56e62ef11aa7ee1f7815e7 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Mon, 28 Nov 2022 00:38:30 +0300 Subject: Avoid refreshing all hooks in secondary worktrees This avoids "ln: failed to access '.git/hooks/foo': Not a directory" console noise. The primary worktree's hooks are used in secondary worktrees anyway. Possibly using 'git rev-parse --git-dir', and putting hooks there would be a better fix? No idea. Change-Id: I846e065d017744e9d8dcee847d48bc1adc66d761 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143358 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- g | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'g') diff --git a/g b/g index fdf95c8278ce..b018561c6775 100755 --- a/g +++ b/g @@ -91,13 +91,16 @@ refresh_all_hooks() local hook pushd "${COREDIR?}" > /dev/null - for hook_name in "${COREDIR?}/.git-hooks"/* ; do - hook=".git/hooks/${hook_name##*/}" - if [ ! -e "${hook?}" ] || [ -L "${hook?}" ] ; then - rm -f "${hook?}" - ln -sf "${hook_name}" "${hook?}" - fi - done + # There's no ".git" e.g. in a secondary worktree + if [ -d ".git" ]; then + for hook_name in "${COREDIR?}/.git-hooks"/* ; do + hook=".git/hooks/${hook_name##*/}" + if [ ! -e "${hook?}" ] || [ -L "${hook?}" ] ; then + rm -f "${hook?}" + ln -sf "${hook_name}" "${hook?}" + fi + done + fi for repo in ${SUBMODULES_ALL?} ; do refresh_submodule_hooks "$repo" -- cgit