git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Make rebase save ORIG_HEAD if using current branch

From
Brian Gernhardt <benji@silverinsanity.com>
Date
May 6, 2008, 17:45 UTC
Message-ID
<54536F65-3A06-482E-9806-2E4F643C1024@silverinsanity.com>
In-Reply-To
<481FFB62.9090804@viscovery.net>
On May 6, 2008, at 2:32 AM, Johannes Sixt wrote:
Show 13 quoted lines
> 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?

Show 5 quoted lines
> 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
Previous: Johannes SixtNext: Johannes Sixt
Message 3 of 5 in “Make rebase save ORIG_HEAD if using current branch”
  1. Make rebase save ORIG_HEAD if using current branchBrian Gernhardt, May 6, 2008
  2. Johannes SixtMay 6, 2008
  3. Brian GernhardtMay 6, 2008
  4. Johannes SixtMay 7, 2008
  5. Junio C HamanoMay 7, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.