diff options
author | Junio C Hamano <gitster@pobox.com> | 2013-01-11 16:49:01 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-01-11 16:49:01 -0800 |
commit | b663af57c31cb6353bd86e39b880cc9602262958 (patch) | |
tree | 7aad0671281be8da5ffd926466dafbfec533613a | |
parent | 02cb8da20d2b575df6b81054295a0a1383c5c0e6 (diff) | |
parent | 3e4141d08c8dc1964d53c2ce13de8876d29e6436 (diff) | |
download | git-b663af57c31cb6353bd86e39b880cc9602262958.tar.gz |
Merge branch 'ap/merge-stop-at-prepare-commit-msg-failure' into maint
"git merge" started calling prepare-commit-msg hook like "git
commit" does some time ago, but forgot to pay attention to the exit
status of the hook.
* ap/merge-stop-at-prepare-commit-msg-failure:
merge: Honor prepare-commit-msg return code
-rw-r--r-- | builtin/merge.c | 5 | ||||
-rwxr-xr-x | t/t7505-prepare-commit-msg-hook.sh | 14 |
2 files changed, 17 insertions, 2 deletions
diff --git a/builtin/merge.c b/builtin/merge.c index a96e8eac19..3a31c4bc25 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -800,8 +800,9 @@ static void prepare_to_commit(struct commit_list *remoteheads) if (0 < option_edit) strbuf_add_lines(&msg, "# ", comment, strlen(comment)); write_merge_msg(&msg); - run_hook(get_index_file(), "prepare-commit-msg", - git_path("MERGE_MSG"), "merge", NULL, NULL); + if (run_hook(get_index_file(), "prepare-commit-msg", + git_path("MERGE_MSG"), "merge", NULL, NULL)) + abort_commit(remoteheads, NULL); if (0 < option_edit) { if (launch_editor(git_path("MERGE_MSG"), NULL, NULL)) abort_commit(remoteheads, NULL); diff --git a/t/t7505-prepare-commit-msg-hook.sh b/t/t7505-prepare-commit-msg-hook.sh index 5b4b694f18..357375151d 100755 --- a/t/t7505-prepare-commit-msg-hook.sh +++ b/t/t7505-prepare-commit-msg-hook.sh @@ -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 |