Skip to content

Commit 47bfdfb

Browse files
raalkmlgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent af6d1d6 commit 47bfdfb

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

builtin/pull.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ static char *opt_edit;
8484
static char *cleanup_arg;
8585
static char *opt_ff;
8686
static char *opt_verify_signatures;
87+
static char *opt_verify;
8788
static int opt_autostash = -1;
8889
static int config_autostash;
8990
static int check_trust_level = 1;
@@ -160,6 +161,9 @@ static struct option pull_options[] = {
160161
OPT_PASSTHRU(0, "ff-only", &opt_ff, NULL,
161162
N_("abort if fast-forward is not possible"),
162163
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),
163167
OPT_PASSTHRU(0, "verify-signatures", &opt_verify_signatures, NULL,
164168
N_("verify that the named commit has a valid GPG signature"),
165169
PARSE_OPT_NOARG),
@@ -675,6 +679,8 @@ static int run_merge(void)
675679
strvec_pushf(&args, "--cleanup=%s", cleanup_arg);
676680
if (opt_ff)
677681
strvec_push(&args, opt_ff);
682+
if (opt_verify)
683+
strvec_push(&args, opt_verify);
678684
if (opt_verify_signatures)
679685
strvec_push(&args, opt_verify_signatures);
680686
strvec_pushv(&args, opt_strategies.v);

t/t5521-pull-options.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,4 +228,28 @@ test_expect_success 'git pull --no-signoff flag cancels --signoff flag' '
228228
test_must_be_empty actual
229229
'
230230

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+
231255
test_done

0 commit comments

Comments
 (0)