Skip to content

Commit fbae70d

Browse files
newrengitster
authored andcommitted
pull: avoid running both merge and rebase
When opt_rebase is true, we still first check if we can fast-forward. If the branch is fast-forwardable, then we can avoid the rebase and just use merge to do the fast-forward logic. However, when commit a6d7eb2 ("pull: optionally rebase submodules (remote submodule changes only)", 2017-06-23) added the ability to rebase submodules it accidentally caused us to run BOTH a merge and a rebase. Add a flag to avoid doing both. This was found when a user had both pull.rebase and rebase.autosquash set to true. In such a case, the running of both merge and rebase would cause ORIG_HEAD to be updated twice (and match HEAD at the end instead of the commit before the rebase started), against expectation. Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b6d4d82 commit fbae70d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

builtin/pull.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
986986

987987
if (opt_rebase) {
988988
int ret = 0;
989+
int ran_ff = 0;
989990
if ((recurse_submodules == RECURSE_SUBMODULES_ON ||
990991
recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND) &&
991992
submodule_touches_in_range(the_repository, &rebase_fork_point, &curr_head))
@@ -1002,10 +1003,12 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
10021003
if (is_descendant_of(merge_head, list)) {
10031004
/* we can fast-forward this without invoking rebase */
10041005
opt_ff = "--ff-only";
1006+
ran_ff = 1;
10051007
ret = run_merge();
10061008
}
10071009
}
1008-
ret = run_rebase(&curr_head, merge_heads.oid, &rebase_fork_point);
1010+
if (!ran_ff)
1011+
ret = run_rebase(&curr_head, merge_heads.oid, &rebase_fork_point);
10091012

10101013
if (!ret && (recurse_submodules == RECURSE_SUBMODULES_ON ||
10111014
recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND))

0 commit comments

Comments
 (0)