Skip to content

Commit adc27d6

Browse files
newrengitster
authored andcommitted
pull: make --rebase and --no-rebase override pull.ff=only
Fix the last few precedence tests failing in t7601 by now implementing the logic to have --[no-]rebase override a pull.ff=only config setting. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent e4dc25e commit adc27d6

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

builtin/pull.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -966,8 +966,22 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
966966

967967
parse_repo_refspecs(argc, argv, &repo, &refspecs);
968968

969-
if (!opt_ff)
969+
if (!opt_ff) {
970970
opt_ff = xstrdup_or_null(config_get_ff());
971+
/*
972+
* A subtle point: opt_ff was set on the line above via
973+
* reading from config. opt_rebase, in contrast, is set
974+
* before this point via command line options. The setting
975+
* of opt_rebase via reading from config (using
976+
* config_get_rebase()) does not happen until later. We
977+
* are relying on the next if-condition happening before
978+
* the config_get_rebase() call so that an explicit
979+
* "--rebase" can override a config setting of
980+
* pull.ff=only.
981+
*/
982+
if (opt_rebase >= 0 && opt_ff && !strcmp(opt_ff, "--ff-only"))
983+
opt_ff = "--ff";
984+
}
971985

972986
if (opt_rebase < 0)
973987
opt_rebase = config_get_rebase(&rebase_unspecified);

t/t7601-merge-pull-config.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,11 @@ test_expect_success '--ff-only takes precedence over pull.rebase=false' '
260260
test_attempts_fast_forward -c pull.rebase=false pull --ff-only
261261
'
262262

263-
test_expect_failure '--no-rebase takes precedence over pull.ff=only' '
263+
test_expect_success '--no-rebase takes precedence over pull.ff=only' '
264264
test_falls_back_to_full_merge -c pull.ff=only pull --no-rebase
265265
'
266266

267-
test_expect_failure '--rebase takes precedence over pull.ff=only' '
267+
test_expect_success '--rebase takes precedence over pull.ff=only' '
268268
test_does_rebase -c pull.ff=only pull --rebase
269269
'
270270

0 commit comments

Comments
 (0)