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

Re: [PATCH] rebase -i: only automatically amend commit if HEAD did not change

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jul 25, 2008, 10:35 UTC
Message-ID
<alpine.DEB.1.00.0807251231560.11976@eeepc-johanness>
In-Reply-To
<7vod4muzck.fsf@gitster.siamese.dyndns.org>
Hi,
On Fri, 25 Jul 2008, Junio C Hamano wrote:
Show 28 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> >> At what point in what valid workflow sequence does HEAD become 
> >> different from dotest/amend?
> >
> > $ rebase -i HEAD~5
> >
> > 	<mark one commit as edit>
> >
> > 	<Whoa! While editing, I realize that this contains an unrelated 
> > 	 bugfix>
> >
> > $ git reset HEAD^
> > $ git add -p
> > $ git commit
> >
> > 	<Edit a bit here, a bit there>
> >
> > $ git rebase --continue
> >
> > Sure it is a pilot error.  It hit this pilot, too.
> > ...
> > In the way that the user certainly did not mean to amend _this_ HEAD.  
> > Another HEAD was marked with "edit".
> 
> Ok; after this "refraining from incorrectly squashing them", how would the
> user edit the one the user originally intended to edit (I am not
> complaining, but asking for information)?

In this case, the two commits are two commits, the editor popped up with rebase --continue contains the original commit message, and all is fine.

Show 15 quoted lines
> So in your workflow example, when there is no pilot error, is this the 
> "ideal" sequence?
> 
> 	$ git rebase -i HEAD~5
>         .. mark one as edit
>         .. ah, the one I wanted to just "edit" actually need to be
>         .. split into two because it has some other thing I need to change
> 	$ git reset HEAD^
> 	$ git add -p
>         $ git stash --keep-index
>         .. test to verify the initial part
>         $ git commit ;# first part of split commit
>         $ git stash pop
>         .. test test
>         $ git add -p
Without pilot error, here has to come a "git commit -c HEAD@{1}".
Show 20 quoted lines
>         $ git rebase --continue ;# gives you the editor to edit
> 
> I wonder if we can make the transcript of the "pilot error" case look like
> this:
> 
> 	$ git rebase -i HEAD~5
> 	...
> 	$ git reset HEAD^
>         .. same as above up to...
>         .. test to verify the initial part
> 	$ git rebase --continue ;# oops
> 	.. gives you the editor to edit the message.
>         .. makes a commit, and says:
>         committed initial part of the change, stopping.
> 	.. ah, the command noticed it and did not escape, thanks!
>         $ git stash pop
>         .. test test
>         $ git add -p
>         $ git rebase --continue ;# gives you the editor to edit
> 	.. and goes on this time.
Possible.

The first hunk (IIRC) of my patch would stay the same, but the second hunk would not fall through to the interactive commit, instead testing if amend exists, _and_ is different from HEAD, and if both are the case, say something helpful and exit.

Ciao, Dscho

Previous: Junio C Hamano
Message 14 of 14 in “rebase -i: only automatically amend commit if HEAD did not change”
  1. rebase -i: only automatically amend commit if HEAD did not changeJohannes Schindelin, Jul 22, 2008
  2. Stephan BeyerJul 22, 2008
  3. Avery PennarunJul 22, 2008
  4. Junio C HamanoJul 22, 2008
  5. Avery PennarunJul 23, 2008
  6. Dmitry PotapovJul 23, 2008
  7. Avery PennarunJul 23, 2008
  8. Johannes SchindelinJul 23, 2008
  9. Avery PennarunJul 23, 2008
  10. Junio C HamanoJul 23, 2008
  11. Johannes SchindelinJul 24, 2008
  12. Stephan BeyerJul 24, 2008
  13. Junio C HamanoJul 25, 2008
  14. Johannes SchindelinJul 25, 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.