diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2017-08-15 13:31:03 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2017-08-15 13:31:26 -0700 |
commit | e97aebd8fed255507fd17ef37a06b042ebed7e77 (patch) | |
tree | 894491ae235da759f03ba3d2b5b8a895e3f166ce /autogen.sh | |
parent | 5c3d0ce3e09bf070bb3c89caa9d88f25d4a39283 (diff) | |
download | emacs-e97aebd8fed255507fd17ef37a06b042ebed7e77.tar.gz |
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.
Diffstat (limited to 'autogen.sh')
-rwxr-xr-x | autogen.sh | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/autogen.sh b/autogen.sh index 70f9cbd245c..d454e41ea75 100755 --- a/autogen.sh +++ b/autogen.sh @@ -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 |