Skip to content

Commit 3400622

Browse files
felipecgitster
authored andcommitted
pull: cleanup autostash check
Currently "git pull --rebase" takes a shortcut in the case a fast-forward merge is possible; run_merge() is called with --ff-only. However, "git merge" didn't have an --autostash option, so, when "git pull --rebase --autostash" was called *and* the fast-forward merge shortcut was taken, then the pull failed. This was fixed in commit f15e7cf (pull: ff --rebase --autostash works in dirty repo, 2017-06-01) by simply skipping the fast-forward merge shortcut. Later on "git merge" learned the --autostash option [a03b555 (merge: teach --autostash option, 2020-04-07)], and so did "git pull" [d9f15d3 (pull: pass --autostash to merge, 2020-04-07)]. Therefore it's not necessary to skip the fast-forward merge shortcut anymore when called with --rebase --autostash. Let's always take the fast-forward merge shortcut by essentially reverting f15e7cf. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 670b81a commit 3400622

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

builtin/pull.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,6 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
947947
struct oid_array merge_heads = OID_ARRAY_INIT;
948948
struct object_id orig_head, curr_head;
949949
struct object_id rebase_fork_point;
950-
int autostash;
951950
int rebase_unspecified = 0;
952951
int can_ff;
953952

@@ -982,8 +981,8 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
982981
if (get_oid("HEAD", &orig_head))
983982
oidclr(&orig_head);
984983

985-
autostash = config_autostash;
986984
if (opt_rebase) {
985+
int autostash = config_autostash;
987986
if (opt_autostash != -1)
988987
autostash = opt_autostash;
989988

@@ -1065,13 +1064,12 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
10651064
recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND) &&
10661065
submodule_touches_in_range(the_repository, &upstream, &curr_head))
10671066
die(_("cannot rebase with locally recorded submodule modifications"));
1068-
if (!autostash) {
1069-
if (can_ff) {
1070-
/* we can fast-forward this without invoking rebase */
1071-
opt_ff = "--ff-only";
1072-
ran_ff = 1;
1073-
ret = run_merge();
1074-
}
1067+
1068+
if (can_ff) {
1069+
/* we can fast-forward this without invoking rebase */
1070+
opt_ff = "--ff-only";
1071+
ran_ff = 1;
1072+
ret = run_merge();
10751073
}
10761074
if (!ran_ff)
10771075
ret = run_rebase(&newbase, &upstream);

0 commit comments

Comments
 (0)