* [PATCH] Make rebase save ORIG_HEAD if using current branch @ 2008-05-06 5:19 Brian Gernhardt 2008-05-06 6:32 ` Johannes Sixt 0 siblings, 1 reply; 5+ messages in thread From: Brian Gernhardt @ 2008-05-06 5:19 UTC (permalink / raw) To: Git List; +Cc: Junio C Hamano This makes rebase act a little more like merge when working on the current branch. This is particularly useful for `git pull --rebase` Signed-off-by: Brian Gernhardt <benji@silverinsanity.com> --- I was trying to figure out why reviewing the new changes in git was so hard using my `git log ORIG_HEAD..` alias. Turns out my ORIG_HEAD hadn't been updated since Feburary, which is when I set branch.master.rebase to true. I think ORIG_HEAD should be set every time a pull changes HEAD, whether by a merge or rebase. Making rebase act like merge seemed more elegant than having git-pull set ORIG_HEAD iff using rebase. git-rebase.sh | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/git-rebase.sh b/git-rebase.sh index 9b13b83..8d54d9f 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -342,6 +342,7 @@ case "$#" in branch_name=HEAD ;# detached fi branch=$(git rev-parse --verify "${branch_name}^0") || exit + echo "$branch" > "$GIT_DIR/ORIG_HEAD" ;; esac orig_head=$branch -- 1.5.5.1.242.g558e8 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] Make rebase save ORIG_HEAD if using current branch 2008-05-06 5:19 [PATCH] Make rebase save ORIG_HEAD if using current branch Brian Gernhardt @ 2008-05-06 6:32 ` Johannes Sixt 2008-05-06 17:45 ` Brian Gernhardt 0 siblings, 1 reply; 5+ messages in thread From: Johannes Sixt @ 2008-05-06 6:32 UTC (permalink / raw) To: Brian Gernhardt; +Cc: Git List, Junio C Hamano Brian Gernhardt schrieb: > diff --git a/git-rebase.sh b/git-rebase.sh > index 9b13b83..8d54d9f 100755 > --- a/git-rebase.sh > +++ b/git-rebase.sh > @@ -342,6 +342,7 @@ case "$#" in > branch_name=HEAD ;# detached > fi > branch=$(git rev-parse --verify "${branch_name}^0") || exit > + echo "$branch" > "$GIT_DIR/ORIG_HEAD" 1. You should be using 'git update-ref' here, I think. 2. You should detect errors. 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. -- Hannes ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Make rebase save ORIG_HEAD if using current branch 2008-05-06 6:32 ` Johannes Sixt @ 2008-05-06 17:45 ` Brian Gernhardt 2008-05-07 8:14 ` Johannes Sixt 0 siblings, 1 reply; 5+ messages in thread From: Brian Gernhardt @ 2008-05-06 17:45 UTC (permalink / raw) To: Johannes Sixt; +Cc: Git List, Junio C Hamano On May 6, 2008, at 2:32 AM, Johannes Sixt wrote: > Brian Gernhardt schrieb: >> diff --git a/git-rebase.sh b/git-rebase.sh >> index 9b13b83..8d54d9f 100755 >> --- a/git-rebase.sh >> +++ b/git-rebase.sh >> @@ -342,6 +342,7 @@ case "$#" in >> branch_name=HEAD ;# detached >> fi >> branch=$(git rev-parse --verify "${branch_name}^0") || exit >> + echo "$branch" > "$GIT_DIR/ORIG_HEAD" > > 1. You should be using 'git update-ref' here, I think. > 2. You should detect errors. This is exactly how git-merge.sh does it. While that's not a good argument for adding this, perhaps merge should be updated as well. And presumably update-ref will make detecting errors easy. But is being unable to set ORIG_HEAD an error that should stop the entire process? > 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. I put it where I did because I thought it would only make sense when rebasing the current HEAD (instead of the two argument version that switches first). Duplicating the logic to determine that later seemed wasteful. 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.) ~~ Brian ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Make rebase save ORIG_HEAD if using current branch 2008-05-06 17:45 ` Brian Gernhardt @ 2008-05-07 8:14 ` Johannes Sixt 2008-05-07 14:30 ` Junio C Hamano 0 siblings, 1 reply; 5+ messages in thread From: Johannes Sixt @ 2008-05-07 8:14 UTC (permalink / raw) To: Brian Gernhardt; +Cc: Git List, Junio C Hamano Brian Gernhardt schrieb: > On May 6, 2008, at 2:32 AM, Johannes Sixt wrote: >> Brian Gernhardt schrieb: >>> + echo "$branch" > "$GIT_DIR/ORIG_HEAD" >> >> 1. You should be using 'git update-ref' here, I think. >> 2. You should detect errors. > > This is exactly how git-merge.sh does it. While that's not a good > argument for adding this, perhaps merge should be updated as well. And > presumably update-ref will make detecting errors easy. But is being > unable to set ORIG_HEAD an error that should stop the entire process? Probably not. >> 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. > > I put it where I did because I thought it would only make sense when > rebasing the current HEAD (instead of the two argument version that > switches first). Duplicating the logic to determine that later seemed > wasteful. 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.) Well, I can't think of a use-case where ORIG_HEAD would be extremly useful for _me_, but you argued for one (git pull --rebase), so you make it so that it suits you. I'm just drawing a scenario where ORIG_HEAD possibly is not what you expect. -- Hannes ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Make rebase save ORIG_HEAD if using current branch 2008-05-07 8:14 ` Johannes Sixt @ 2008-05-07 14:30 ` Junio C Hamano 0 siblings, 0 replies; 5+ messages in thread From: Junio C Hamano @ 2008-05-07 14:30 UTC (permalink / raw) To: Johannes Sixt; +Cc: Brian Gernhardt, Git List Johannes Sixt <j.sixt@viscovery.net> writes: >>> 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. >> ... 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. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-05-07 14:31 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-05-06 5:19 [PATCH] Make rebase save ORIG_HEAD if using current branch Brian Gernhardt 2008-05-06 6:32 ` Johannes Sixt 2008-05-06 17:45 ` Brian Gernhardt 2008-05-07 8:14 ` Johannes Sixt 2008-05-07 14:30 ` Junio C Hamano
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).