summaryrefslogtreecommitdiff
path: root/g
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2022-11-28 00:38:30 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2022-11-28 05:18:12 +0100
commit1fd42472e2b1a2169d56e62ef11aa7ee1f7815e7 (patch)
treea01a2b8f7aa989b40ad46a50def5c2817ef5ad44 /g
parent360b5861fb46353e7a6b9f5abf13339cd719a8df (diff)
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.kaganski@collabora.com>
Diffstat (limited to 'g')
-rwxr-xr-xg17
1 files changed, 10 insertions, 7 deletions
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"