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>
This commit is contained in:
Mike Kaganski
2022-11-28 00:38:30 +03:00
parent 360b5861fb
commit 1fd42472e2

3
g
View File

@@ -91,6 +91,8 @@ refresh_all_hooks()
local hook local hook
pushd "${COREDIR?}" > /dev/null pushd "${COREDIR?}" > /dev/null
# There's no ".git" e.g. in a secondary worktree
if [ -d ".git" ]; then
for hook_name in "${COREDIR?}/.git-hooks"/* ; do for hook_name in "${COREDIR?}/.git-hooks"/* ; do
hook=".git/hooks/${hook_name##*/}" hook=".git/hooks/${hook_name##*/}"
if [ ! -e "${hook?}" ] || [ -L "${hook?}" ] ; then if [ ! -e "${hook?}" ] || [ -L "${hook?}" ] ; then
@@ -98,6 +100,7 @@ refresh_all_hooks()
ln -sf "${hook_name}" "${hook?}" ln -sf "${hook_name}" "${hook?}"
fi fi
done done
fi
for repo in ${SUBMODULES_ALL?} ; do for repo in ${SUBMODULES_ALL?} ; do
refresh_submodule_hooks "$repo" refresh_submodule_hooks "$repo"