diff options
| -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 | |||
| 327 | cmp -- build-aux/git-hooks/$hook "$hooks/$hook" >/dev/null 2>&1 || | 327 | cmp -- build-aux/git-hooks/$hook "$hooks/$hook" >/dev/null 2>&1 || |
| 328 | tailored_hooks="$tailored_hooks $hook" | 328 | tailored_hooks="$tailored_hooks $hook" |
| 329 | done | 329 | done |
| 330 | |||
| 331 | git_sample_hook_src () | ||
| 332 | { | ||
| 333 | hook=$1 | ||
| 334 | src=$hooks/$hook.sample | ||
| 335 | if test ! -r "$src"; then | ||
| 336 | case $hook in | ||
| 337 | applypatch-msg) src=build-aux/git-hooks/commit-msg;; | ||
| 338 | pre-applypatch) src=build-aux/git-hooks/pre-commit;; | ||
| 339 | esac | ||
| 340 | fi | ||
| 341 | } | ||
| 330 | for hook in applypatch-msg pre-applypatch; do | 342 | for hook in applypatch-msg pre-applypatch; do |
| 331 | cmp -- "$hooks/$hook.sample" "$hooks/$hook" >/dev/null 2>&1 || | 343 | git_sample_hook_src $hook |
| 344 | cmp -- "$src" "$hooks/$hook" >/dev/null 2>&1 || | ||
| 332 | sample_hooks="$sample_hooks $hook" | 345 | sample_hooks="$sample_hooks $hook" |
| 333 | done | 346 | done |
| 334 | 347 | ||
| @@ -336,6 +349,11 @@ if test -n "$tailored_hooks$sample_hooks"; then | |||
| 336 | if $do_git; then | 349 | if $do_git; then |
| 337 | echo "Installing git hooks..." | 350 | echo "Installing git hooks..." |
| 338 | 351 | ||
| 352 | if test ! -d "$hooks"; then | ||
| 353 | printf "mkdir -p -- '%s'\\n" "$hooks" | ||
| 354 | mkdir -p -- "$hooks" || exit | ||
| 355 | fi | ||
| 356 | |||
| 339 | if test -n "$tailored_hooks"; then | 357 | if test -n "$tailored_hooks"; then |
| 340 | for hook in $tailored_hooks; do | 358 | for hook in $tailored_hooks; do |
| 341 | dst=$hooks/$hook | 359 | dst=$hooks/$hook |
| @@ -346,8 +364,9 @@ if test -n "$tailored_hooks$sample_hooks"; then | |||
| 346 | 364 | ||
| 347 | if test -n "$sample_hooks"; then | 365 | if test -n "$sample_hooks"; then |
| 348 | for hook in $sample_hooks; do | 366 | for hook in $sample_hooks; do |
| 367 | git_sample_hook_src $hook | ||
| 349 | dst=$hooks/$hook | 368 | dst=$hooks/$hook |
| 350 | cp $cp_options -- "$dst.sample" "$dst" || exit | 369 | cp $cp_options -- "$src" "$dst" || exit |
| 351 | chmod -- a-w "$dst" || exit | 370 | chmod -- a-w "$dst" || exit |
| 352 | done | 371 | done |
| 353 | fi | 372 | fi |