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

17
g
View File

@@ -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"