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

Re: bug?: ORIG_HEAD incorrect after reset during git-rebase -i

From
Philippe Blain <levraiphilippeblain@gmail.com>
Date
Jan 5, 2023, 00:11 UTC
Message-ID
<ef389a14-8513-4650-21e4-89421a24df2d@gmail.com>
In-Reply-To
<CA+JQ7M9G8HqqieRAK3C6csMM93PHOmaMd8GMPrDEfogWG0bteA@mail.gmail.com>
Hi Phillip and Erik,
Le 2021-12-16 à 11:44, Erik Cervin Edin a écrit :
Show 8 quoted lines
> Hi Phillip,
> 
> Yes, I know.
> It's just that I was under the impression ORIG_HEAD was to be reverted
> to .git/rebase-merge/orig-head at the finish of the rebase.
> Personally, it's the behavior I would expect.
> 
> Thanks for the tips.

I just hit the same bug (I think it qualifies as one). In fact git-rebase(1) explicitely mentions that ORIG_HEAD is set to the branch tip before the rebase starts:

$ git grep -C2 ORIG_HEAD Documentation/git-rebase.txt Documentation/git-rebase.txt-36-The current branch is reset to `<upstream>` or `<newbase>` if the Documentation/git-rebase.txt-37-`--onto` option was supplied. This has the exact same effect as Documentation/git-rebase.txt:38:50:`git reset --hard <upstream>` (or `<newbase>`). `ORIG_HEAD` is set Documentation/git-rebase.txt-39-to point at the tip of the branch before the reset. Documentation/git-rebase.txt-40-

Here is my runnable reproducer. It is slightly more complicated than Erik's, since I split the second commit in two, but this is not necessary to trigger the bug; just running 'git reset HEAD^' as Erik wrote is enough.

```bash #!/bin/bash rm -rf repro git init repro ( cd repro # Create 3 commits cat << EOF >test hello every one EOF git add test git commit -m initial cat << EOF >test hello

add new lines
every
and also here

one EOF git commit -am second cat << EOF >test hello

add new lines
every
and also here
one

still more changes EOF git commit -am third # Rebase to split the second commit GIT_SEQUENCE_EDITOR="sed -ie '1 s/^p /e /'" git rebase -i HEAD~2 git reset HEAD^ cat << EOF >test hello

add new lines

every one EOF git ci -am "second 1/2" cat <<EOF >test hello

add new lines
every
and also here

one EOF git ci -am "second 2/2" # Finish rebase and demonstrate bug git rebase --continue echo --- echo "@{1} is :" git log -1 @{1} echo "ORIG_HEAD is :" git log -1 ORIG_HEAD

) ```

Cheers,
Philippe.
Previous: Erik Cervin EdinNext: Phillip Wood
Message 4 of 7 in “bug?: ORIG_HEAD incorrect after reset during git-rebase -i”
  1. Erik Cervin EdinDec 16, 2021
  2. Phillip WoodDec 16, 2021
  3. Erik Cervin EdinDec 16, 2021
  4. Philippe BlainJan 5, 2023
  5. Phillip WoodJan 6, 2023
  6. Philippe BlainJan 7, 2023
  7. Philippe BlainJan 7, 2023

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.