summaryrefslogtreecommitdiff
path: root/builtin/pull.c
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2020-03-27 21:51:40 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-03-27 22:54:54 (GMT)
commitfbae70ddc6da7df3f901d95da2b11b2cb58c8a29 (patch)
tree773b411fae5b202d3d0436ed973d53de239109bc /builtin/pull.c
parentb6d4d82bd5a49197d5d2f4f81c08da0d461cfcf1 (diff)
downloadgit-fbae70ddc6da7df3f901d95da2b11b2cb58c8a29.zip
git-fbae70ddc6da7df3f901d95da2b11b2cb58c8a29.tar.gz
git-fbae70ddc6da7df3f901d95da2b11b2cb58c8a29.tar.bz2
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 a6d7eb2c7a ("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 <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/pull.c')
-rw-r--r--builtin/pull.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/builtin/pull.c b/builtin/pull.c
index d25ff13..e79ce01 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -986,6 +986,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
if (opt_rebase) {
int ret = 0;
+ int ran_ff = 0;
if ((recurse_submodules == RECURSE_SUBMODULES_ON ||
recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND) &&
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)
if (is_descendant_of(merge_head, list)) {
/* we can fast-forward this without invoking rebase */
opt_ff = "--ff-only";
+ ran_ff = 1;
ret = run_merge();
}
}
- ret = run_rebase(&curr_head, merge_heads.oid, &rebase_fork_point);
+ if (!ran_ff)
+ ret = run_rebase(&curr_head, merge_heads.oid, &rebase_fork_point);
if (!ret && (recurse_submodules == RECURSE_SUBMODULES_ON ||
recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND))