From 2a59c1890f81bffc1db79cae4482ce2b706b0f79 Mon Sep 17 00:00:00 2001 From: Marek Suscak Date: Wed, 9 Dec 2020 15:53:29 +0100 Subject: [PATCH] Use if instead of && in git hooks (#680) This prevents a Git hook from issuing a non-zero exit status if the condition is the last line of the hook. --- git_template/hooks/post-checkout | 5 ++++- git_template/hooks/post-commit | 5 ++++- git_template/hooks/post-merge | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/git_template/hooks/post-checkout b/git_template/hooks/post-checkout index ddc681f..992ebfa 100755 --- a/git_template/hooks/post-checkout +++ b/git_template/hooks/post-checkout @@ -1,6 +1,9 @@ #!/bin/sh local_hook="$HOME"/.git_template.local/hooks/post-checkout -[ -f "$local_hook" ] && . "$local_hook" + +if [ -f "$local_hook" ]; then + . "$local_hook"; +fi .git/hooks/ctags >/dev/null 2>&1 & diff --git a/git_template/hooks/post-commit b/git_template/hooks/post-commit index cbc1d57..d2bab05 100755 --- a/git_template/hooks/post-commit +++ b/git_template/hooks/post-commit @@ -1,6 +1,9 @@ #!/bin/sh local_hook="$HOME"/.git_template.local/hooks/post-commit -[ -f "$local_hook" ] && . "$local_hook" + +if [ -f "$local_hook" ]; then + . "$local_hook"; +fi .git/hooks/ctags >/dev/null 2>&1 & diff --git a/git_template/hooks/post-merge b/git_template/hooks/post-merge index 30e9bd2..2d49b9c 100755 --- a/git_template/hooks/post-merge +++ b/git_template/hooks/post-merge @@ -1,6 +1,9 @@ #!/bin/sh local_hook="$HOME"/.git_template.local/hooks/post-merge -[ -f "$local_hook" ] && . "$local_hook" + +if [ -f "$local_hook" ]; then + . "$local_hook"; +fi .git/hooks/ctags >/dev/null 2>&1 &