]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin/merge.c
Merge branch 'gc/branch-recurse-submodules-fix'
[thirdparty/git.git] / builtin / merge.c
index a94a03384ae6da259a1c6abf5fcd5b4b88b8325a..f178f5a3ee18c71d2acda9455b020f9c03da9509 100644 (file)
@@ -845,15 +845,20 @@ static void prepare_to_commit(struct commit_list *remoteheads)
        struct strbuf msg = STRBUF_INIT;
        const char *index_file = get_index_file();
 
-       if (!no_verify && run_commit_hook(0 < option_edit, index_file, "pre-merge-commit", NULL))
-               abort_commit(remoteheads, NULL);
-       /*
-        * Re-read the index as pre-merge-commit hook could have updated it,
-        * and write it out as a tree.  We must do this before we invoke
-        * the editor and after we invoke run_status above.
-        */
-       if (hook_exists("pre-merge-commit"))
-               discard_cache();
+       if (!no_verify) {
+               int invoked_hook;
+
+               if (run_commit_hook(0 < option_edit, index_file, &invoked_hook,
+                                   "pre-merge-commit", NULL))
+                       abort_commit(remoteheads, NULL);
+               /*
+                * Re-read the index as pre-merge-commit hook could have updated it,
+                * and write it out as a tree.  We must do this before we invoke
+                * the editor and after we invoke run_status above.
+                */
+               if (invoked_hook)
+                       discard_cache();
+       }
        read_cache_from(index_file);
        strbuf_addbuf(&msg, &merge_msg);
        if (squash)
@@ -875,7 +880,8 @@ static void prepare_to_commit(struct commit_list *remoteheads)
                append_signoff(&msg, ignore_non_trailer(msg.buf, msg.len), 0);
        write_merge_heads(remoteheads);
        write_file_buf(git_path_merge_msg(the_repository), msg.buf, msg.len);
-       if (run_commit_hook(0 < option_edit, get_index_file(), "prepare-commit-msg",
+       if (run_commit_hook(0 < option_edit, get_index_file(), NULL,
+                           "prepare-commit-msg",
                            git_path_merge_msg(the_repository), "merge", NULL))
                abort_commit(remoteheads, NULL);
        if (0 < option_edit) {
@@ -884,7 +890,7 @@ static void prepare_to_commit(struct commit_list *remoteheads)
        }
 
        if (!no_verify && run_commit_hook(0 < option_edit, get_index_file(),
-                                         "commit-msg",
+                                         NULL, "commit-msg",
                                          git_path_merge_msg(the_repository), NULL))
                abort_commit(remoteheads, NULL);