pull: honor --no-verify and do not call the commit-msg hook

The option was incorrectly auto-translated to "--no-verify-signatures", which causes the unexpected effect of the hook being called. And an even more unexpected effect of disabling verification of signatures. The manual page describes the option to behave same as the similarly named option of "git merge", which seems to be the original intention of this option in the "pull" command. Signed-off-by: Alexander Riesen <raa.lkml@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Alex Riesen committed Oct 28, 2021 at 17:46 UTC 47bfdfb3fd3b4752d2292a6744fae9abe37b8f1e
2 files changed +30
builtin/pull.c
+6
@@ -84,6 +84,7 @@ static char *opt_edit;
84 static char *cleanup_arg;
85 static char *opt_ff;
86 static char *opt_verify_signatures;
87 +static char *opt_verify;
88 static int opt_autostash = -1;
89 static int config_autostash;
90 static int check_trust_level = 1;
@@ -160,6 +161,9 @@ static struct option pull_options[] = {
161 OPT_PASSTHRU(0, "ff-only", &opt_ff, NULL,
162 N_("abort if fast-forward is not possible"),
163 PARSE_OPT_NOARG | PARSE_OPT_NONEG),
164 + OPT_PASSTHRU(0, "verify", &opt_verify, NULL,
165 + N_("control use of pre-merge-commit and commit-msg hooks"),
166 + PARSE_OPT_NOARG),
167 OPT_PASSTHRU(0, "verify-signatures", &opt_verify_signatures, NULL,
168 N_("verify that the named commit has a valid GPG signature"),
169 PARSE_OPT_NOARG),
@@ -675,6 +679,8 @@ static int run_merge(void)
679 strvec_pushf(&args, "--cleanup=%s", cleanup_arg);
680 if (opt_ff)
681 strvec_push(&args, opt_ff);
682 + if (opt_verify)
683 + strvec_push(&args, opt_verify);
684 if (opt_verify_signatures)
685 strvec_push(&args, opt_verify_signatures);
686 strvec_pushv(&args, opt_strategies.v);
t/t5521-pull-options.sh
+24
@@ -228,4 +228,28 @@ test_expect_success 'git pull --no-signoff flag cancels --signoff flag' '
228 test_must_be_empty actual
229 '
230
231 +test_expect_success 'git pull --no-verify flag passed to merge' '
232 + test_when_finished "rm -fr src dst actual" &&
233 + git init src &&
234 + test_commit -C src one &&
235 + git clone src dst &&
236 + write_script dst/.git/hooks/commit-msg <<-\EOF &&
237 + false
238 + EOF
239 + test_commit -C src two &&
240 + git -C dst pull --no-ff --no-verify
241 +'
242 +
243 +test_expect_success 'git pull --no-verify --verify passed to merge' '
244 + test_when_finished "rm -fr src dst actual" &&
245 + git init src &&
246 + test_commit -C src one &&
247 + git clone src dst &&
248 + write_script dst/.git/hooks/commit-msg <<-\EOF &&
249 + false
250 + EOF
251 + test_commit -C src two &&
252 + test_must_fail git -C dst pull --no-ff --no-verify --verify
253 +'
254 +
255 test_done