g |   17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

New commits:
commit 1fd42472e2b1a2169d56e62ef11aa7ee1f7815e7
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Mon Nov 28 00:38:30 2022 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Mon Nov 28 05:18:12 2022 +0100

    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 <mike.kagan...@collabora.com>

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"

Reply via email to