merge: Honor prepare-commit-msg return code

65969d4 (merge: honor prepare-commit-msg hook, 2011-02-14) tried to
make "git commit" and "git merge" consistent, because a merge that
required user assistance has to be concluded with "git commit", but
back then only "git commit" triggered prepare-commit-msg hook.

When it added a call to run the prepare-commit-msg hook, however, it
forgot to check the exit code from the hook like "git commit" does,
and ended up replacing one inconsistency with another.

When prepare-commit-msg hook that is run from "git merge" exits with
a non-zero status, abort the commit.

Signed-off-by: Antoine Pelisse <apelisse@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Antoine Pelisse
2013-01-02 19:42:50 +01:00
committed by Junio C Hamano
parent 15999998fb
commit 3e4141d08c
2 changed files with 17 additions and 2 deletions

View File

@ -167,5 +167,19 @@ test_expect_success 'with failing hook (--no-verify)' '
'
test_expect_success 'with failing hook (merge)' '
git checkout -B other HEAD@{1} &&
echo "more" >> file &&
git add file &&
rm -f "$HOOK" &&
git commit -m other &&
write_script "$HOOK" <<-EOF
exit 1
EOF
git checkout - &&
test_must_fail git merge other
'
test_done