Re: [PATCH 5/5] git-rebase.txt: add a note about 'ORIG_HEAD' being overwritten
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 8, 2023, 02:16 UTC
- Message-ID
- <xmqq4jt122k2.fsf@gitster.g>
- In-Reply-To
- <9ef427a9a2adfb6a47d13103f00a64df96725560.1673120359.git.gitgitgadget@gmail.com>
"Philippe Blain via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 8 quoted lines
> From: Philippe Blain <levraiphilippeblain@gmail.com> > > 'ORIG_HEAD' is written at the start of the rebase, but is not guaranteed > to still point to the original branch tip at the end of the rebase. > > Indeed, using other commands that write 'ORIG_HEAD' during the rebase, > like splitting a commit using 'git reset HEAD^', will lead to 'ORIG_HEAD' > being overwritten.
Is that a news? If a user does "reset", the user is asking that HEAD is changed and the old state kept in ORIG_HEAD at the same time, so while it is not wrong per-se to say that user can clobber ORIG_HEAD after rebase sets it first, it is pretty much expected, no?
What would be unexpected is if "rebase" overwrote ORIG_HEAD after user did all these other things while it gave control back and then it took control back, and it would be worth documenting.
Having said that, I do not mind documenting this. I am not sure "is not guaranteed" is a good way to phrase what happens, though.
Show 6 quoted lines
> +[NOTE]
> +`ORIG_HEAD` is not guaranteed to still point to the previous branch tip
> +at the end of the rebase if other commands that write that pseudo-ref
> +(e.g. `git reset`) are used during the rebase. The previous branch tip,
> +however, is accessible using the reflog of the current branch
> +(i.e. `@{1}`, see linkgit:gitrevisions[7]). `ORIG_HEAD` is set to point at the tip of the previous branch
when `rebase` begins, but the user can run commands (e.g. "git
reset") that overwrites `ORIG_HEAD` while `rebase` gives control
to the user (e.g. while asking to resolve conflict).It is excellent to mention reflog, which is very much an upward compatible replacement of ORIG_HEAD.
Thanks.