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 24, 2008, 12:20 UTC
Message-ID
<alpine.DEB.1.00.0807241311450.8986@racer>
In-Reply-To
<7vmyk888z5.fsf@gitster.siamese.dyndns.org>
Hi,
On Wed, 23 Jul 2008, Junio C Hamano wrote:
Show 11 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> > If the user called "rebase -i", marked a commit as "edit", "rebase 
> > --continue" would automatically amend the commit when there were 
> > staged changes.
> >
> > However, this is actively wrong when the current commit is not the one 
> > marked with "edit".  So guard against this.
> 
> 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.
Show 13 quoted lines
> > @@ -419,7 +419,9 @@ do
> >  		else
> >  			. "$DOTEST"/author-script ||
> >  				die "Cannot find the author identity"
> > -			if test -f "$DOTEST"/amend
> > +			if test -f "$DOTEST"/amend &&
> > +				test $(git rev-parse HEAD) = \
> > +					$(cat "$DOTEST"/amend)
> >  			then
> >  				git reset --soft HEAD^ ||
> >  				die "Cannot rewind the HEAD"
> 
> In what way is this "guarding against it"?

In the way that the user certainly did not mean to amend _this_ HEAD. Another HEAD was marked with "edit".

By not amending, the user has a chance to fix anything unintended in another rebase -i more easily, since the two commits have not been squashed together.

'course, the user should have seen in the editor that popped up that she is squashing two different commits, should have deleted the whole commit message to abort, make the independent commit herself (finding the correct commit to steal the commit message from), then run rebase --continue (which would no longer commit anything, there being nothing to).

However, that course of action is a bit unintuitive.

The way it runs with my patch, at least a user has a chance to fix it up without a Git expert standing nearby.

I will definitely keep this in my personal fork, even in my personal fork of "master" during the rc period. But if you think it is not worth it, and others seem to be utterly disinterested (instead discussing behavior changes), I will not push further.

Ciao, Dscho

Previous: Junio C HamanoNext: Stephan Beyer
Message 11 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.