aboutsummaryrefslogtreecommitdiffstats
path: root/builtin/rebase.c
diff options
context:
space:
mode:
authorPhillip Wood <phillip.wood@dunelm.org.uk>2022-01-26 13:05:48 +0000
committerJunio C Hamano <gitster@pobox.com>2022-01-26 12:08:53 -0800
commitcd1528ef8ef9847fc27cff4016bf073f04729504 (patch)
tree54e0d712139312788ffc4929e8352d042c60944f /builtin/rebase.c
parent7700ab087b82f71d19134141045b95063e407344 (diff)
downloadgit-cd1528ef8ef9847fc27cff4016bf073f04729504.tar.gz
rebase --apply: set ORIG_HEAD correctly
At the start of a rebase, ORIG_HEAD is updated to the tip of the branch being rebased. Unfortunately reset_head() always uses the current value of HEAD for this which is incorrect if the rebase is started with "git rebase <upstream> <branch>" as in that case ORIG_HEAD should be updated to <branch>. This only affects the "apply" backend as the "merge" backend does not yet use reset_head() for the initial checkout. Fix this by passing in orig_head when calling reset_head() and add some regression tests. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/rebase.c')
-rw-r--r--builtin/rebase.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/builtin/rebase.c b/builtin/rebase.c
index b55a9cff05..e942c300f8 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -1769,6 +1769,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
strbuf_addf(&msg, "%s: checkout %s",
getenv(GIT_REFLOG_ACTION_ENVIRONMENT), options.onto_name);
ropts.oid = &options.onto->object.oid;
+ ropts.orig_head = &options.orig_head,
ropts.flags = RESET_HEAD_DETACH | RESET_ORIG_HEAD |
RESET_HEAD_RUN_POST_CHECKOUT_HOOK;
ropts.head_msg = msg.buf;