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

Re: minor interactive rebase regression: HEAD points to wrong commit while rewording

From
SZEDER Gábor <szeder.dev@gmail.com>
Date
Aug 12, 2019, 18:56 UTC
Message-ID
<20190812185618.GN20404@szeder.dev>
In-Reply-To
<xmqqsgq69rky.fsf@gitster-ct.c.googlers.com>
On Mon, Aug 12, 2019 at 11:17:01AM -0700, Junio C Hamano wrote:
Show 23 quoted lines
> SZEDER Gábor <szeder.dev@gmail.com> writes:
> 
> > ...
> > So far so good.
> > Save the updated commit message, and after the editor opens up the
> > third commit's log message, check again where HEAD is pointing to now:
> >
> >   ~/tmp/reword (master +|REBASE-i 2/3)$ head -n1 .git/COMMIT_EDITMSG 
> >   third
> >   ~/tmp/reword (master +|REBASE-i 2/3)$ git log --oneline -1
> >   c3db735 (HEAD) second - updated
> >
> > As you can see, HEAD still points to the (now rewritten) second
> > commit.
> >
> > It's only HEAD,...
> 
> Yuck.
> 
> That would still be annoying to some people and outright buggy to
> others, if their workflow relies on HEAD (e.g. compare with HEAD
> while reviewing the log messsage) and then now they instead need to
> adjust (e.g. compare with the index instead).

Well, it's caused by a 2.5 year old commit, so either all those people have been lucky so far (or just don't do subsequent rewords?), or those who stumbled upon it already adjusted without complaining to us.

> Perhaps you are one of them

No; during the second reword I ran 'git log -2' in the other terminal (wanted to copy a sentence from the previous, just reworded commit), and noticed that the two listed commits were "off by one".

BTW, rewriting the first commit appears to be important. When doing an edit-reword of two subsequent commits, then this issue only happens if the edit actually rewrites the commit. However, when, instead of editing anything, I do a 'git rebase --continue' right away, then HEAD points to where it should during the subsequent reword.

Anyway, Cc:-ing Dscho for his rebase expertise.
Previous: Junio C HamanoNext: Phillip Wood
Message 3 of 10 in “minor interactive rebase regression: HEAD points to wrong commit while rewording”
  1. SZEDER GáborAug 12, 2019
  2. Junio C HamanoAug 12, 2019
  3. SZEDER GáborAug 12, 2019
  4. Phillip WoodAug 12, 2019
  5. Johannes SchindelinAug 14, 2019
  6. SZEDER GáborAug 14, 2019
  7. SZEDER GáborAug 14, 2019
  8. Phillip WoodAug 15, 2019
  9. Junio C HamanoAug 15, 2019
  10. Junio C HamanoAug 15, 2019

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.