Commit e97aebd8 authored by Paul Eggert's avatar Paul Eggert

Do not assume regular Git .git/hooks dir

Apparently Gitlab doesn’t create .git/hooks, like regular Git does.
Problem reported by Ted Zlatanov in:
http://lists.gnu.org/archive/html/emacs-devel/2017-08/msg00380.html
* autogen.sh (git_sample_hook_src): New function.  Use it to work
even if .git/hooks or its samples do not exist.
parent 5c3d0ce3
......@@ -327,8 +327,21 @@ for hook in commit-msg pre-commit; do
cmp -- build-aux/git-hooks/$hook "$hooks/$hook" >/dev/null 2>&1 ||
tailored_hooks="$tailored_hooks $hook"
done
git_sample_hook_src ()
{
hook=$1
src=$hooks/$hook.sample
if test ! -r "$src"; then
case $hook in
applypatch-msg) src=build-aux/git-hooks/commit-msg;;
pre-applypatch) src=build-aux/git-hooks/pre-commit;;
esac
fi
}
for hook in applypatch-msg pre-applypatch; do
cmp -- "$hooks/$hook.sample" "$hooks/$hook" >/dev/null 2>&1 ||
git_sample_hook_src $hook
cmp -- "$src" "$hooks/$hook" >/dev/null 2>&1 ||
sample_hooks="$sample_hooks $hook"
done
......@@ -336,6 +349,11 @@ if test -n "$tailored_hooks$sample_hooks"; then
if $do_git; then
echo "Installing git hooks..."
if test ! -d "$hooks"; then
printf "mkdir -p -- '%s'\\n" "$hooks"
mkdir -p -- "$hooks" || exit
fi
if test -n "$tailored_hooks"; then
for hook in $tailored_hooks; do
dst=$hooks/$hook
......@@ -346,8 +364,9 @@ if test -n "$tailored_hooks$sample_hooks"; then
if test -n "$sample_hooks"; then
for hook in $sample_hooks; do
git_sample_hook_src $hook
dst=$hooks/$hook
cp $cp_options -- "$dst.sample" "$dst" || exit
cp $cp_options -- "$src" "$dst" || exit
chmod -- a-w "$dst" || exit
done
fi
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment