Re: [PATCH] Make rebase save ORIG_HEAD if using current branch
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:44:34
Johannes Sixt [off-list ref] writes:
quoted
quoted
3. Should ORIG_HEAD better be set at the end of the rebase, not at the beginning? Because if the rebase stops for some reason, and then you do a 'git reset', you'll have overwritten the ORIG_HEAD that you have set here.
Very true. If the purpose of this is to view "diff/log ORIG_HEAD.." after
"pull --rebase", setting it there does not make much sense. In any case,
"diff/log branch@{1}..." will give you the same information unless you are
rebasing an already detached HEAD, so letting ORIG_HEAD get overwritten
like this patch does is not the end of the world, but then the original
issue of the lack of ORIG_HEAD is not much of an issue either with that
logic.
What the patch implements would be an ORIG_HEAD that only sometimes works
(iow, does not work if you did reset during rebasing session), which is
not what people can rely on. Teaching people a more reliable way of using
reflog, which incidentally is also a consistent way between "pull" and
"pull --rebase", might be better than that. I would agree that the ideal
thing is an ORIG_HEAD that always works, because it gives us the
consistency between the normal "pull" and "pull --rebase", though.
quoted
... Also, might you want to access the original HEAD during a rebase conflict? (Although that would argue that ORIG_HEAD should be set for all rebases, to $upstream.)
I often find it useful to say "show-branch HEAD topic" while rebasing the topic (gitk HEAD...topic would work equally well), taking advantage of the fact that the topic stays at the original position until rebase completes. You do not need ORIG_HEAD pointing at anywhere to help that history inspection. I do not think setting ORIG_HEAD to $upstream (actually, it should be "onto") makes much sense. After a normal "pull", what you can inspect with "diff/log ORIG_HEAD" is the newly acquired history. If we were to allow ORIG_HEAD to be used after a "pull --rebase" in a similar way, if you make it point at "the onto" commit, "diff/log ORIG_HEAD" would show the changes _you_ had before you did rebase that you carried forward, not the new history you acquired with the "pull --rebase" operation.