merge: do no-verify like commit

f8b863598c ("builtin/merge: honor commit-msg hook for merges", 2017-09-07) introduced the no-verify flag to merge for bypassing the commit-msg hook, though in a different way from the implementation in commit.c. Change the implementation in merge.c to be the same as in commit.c so that both do the same in the same way. This also changes the output of "git merge --help" to be more clear that the hook return code is respected by default. [js: * reworded commit message * squashed documentation changes from original series' patch 3/4 ] Signed-off-by: Michael J Gruber <git@grubix.eu> Signed-off-by: Josh Steadmon <steadmon@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael J Gruber committed Aug 7, 2019 at 11:57 UTC a1f3dd7eb303d924f90da30808f7702869430321
3 files changed +8 -4
Documentation/git-merge.txt
+1 -1
@@ -10,7 +10,7 @@ SYNOPSIS
10 --------
11 [verse]
12 'git merge' [-n] [--stat] [--no-commit] [--squash] [--[no-]edit]
13 - [-s <strategy>] [-X <strategy-option>] [-S[<keyid>]]
13 + [--no-verify] [-s <strategy>] [-X <strategy-option>] [-S[<keyid>]]
14 [--[no-]allow-unrelated-histories]
15 [--[no-]rerere-autoupdate] [-m <msg>] [-F <file>] [<commit>...]
16 'git merge' (--continue | --abort | --quit)
Documentation/merge-options.txt
+4
@@ -105,6 +105,10 @@ option can be used to override --squash.
105 +
106 With --squash, --commit is not allowed, and will fail.
107
108 +--no-verify::
109 + This option bypasses the pre-merge and commit-msg hooks.
110 + See also linkgit:githooks[5].
111 +
112 -s <strategy>::
113 --strategy=<strategy>::
114 Use the given merge strategy; can be supplied more than
builtin/merge.c
+3 -3
@@ -81,7 +81,7 @@ static int show_progress = -1;
81 static int default_to_upstream = 1;
82 static int signoff;
83 static const char *sign_commit;
84 -static int verify_msg = 1;
84 +static int no_verify;
85
86 static struct strategy all_strategy[] = {
87 { "recursive", DEFAULT_TWOHEAD | NO_TRIVIAL },
@@ -287,7 +287,7 @@ static struct option builtin_merge_options[] = {
287 N_("GPG sign commit"), PARSE_OPT_OPTARG, NULL, (intptr_t) "" },
288 OPT_BOOL(0, "overwrite-ignore", &overwrite_ignore, N_("update ignored files (default)")),
289 OPT_BOOL(0, "signoff", &signoff, N_("add Signed-off-by:")),
290 - OPT_BOOL(0, "verify", &verify_msg, N_("verify commit-msg hook")),
290 + OPT_BOOL(0, "no-verify", &no_verify, N_("bypass commit-msg hook")),
291 OPT_END()
292 };
293
@@ -842,7 +842,7 @@ static void prepare_to_commit(struct commit_list *remoteheads)
842 abort_commit(remoteheads, NULL);
843 }
844
845 - if (verify_msg && run_commit_hook(0 < option_edit, get_index_file(),
845 + if (!no_verify && run_commit_hook(0 < option_edit, get_index_file(),
846 "commit-msg",
847 git_path_merge_msg(the_repository), NULL))
848 abort_commit(remoteheads, NULL);