From cd1528ef8ef9847fc27cff4016bf073f04729504 Mon Sep 17 00:00:00 2001 From: Phillip Wood Date: Wed, 26 Jan 2022 13:05:48 +0000 Subject: 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 " as in that case ORIG_HEAD should be updated to . 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 Signed-off-by: Junio C Hamano --- reset.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'reset.h') diff --git a/reset.h b/reset.h index 7ef7e43ea8..a28f81829d 100644 --- a/reset.h +++ b/reset.h @@ -22,6 +22,10 @@ struct reset_head_opts { * The commit to checkout/reset to. Defaults to HEAD. */ const struct object_id *oid; + /* + * Optional value to set ORIG_HEAD. Defaults to HEAD. + */ + const struct object_id *orig_head; /* * Optional branch to switch to. */ -- cgit v1.2.3