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

Re: [PATCH 1/2] git-rebase-interactive: do not squash commits on abort

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Sep 9, 2008, 14:17 UTC
Message-ID
<alpine.DEB.1.00.0809091616200.13830@pacific.mpi-cbg.de.mpi-cbg.de>
In-Reply-To
<7v7i9mdvyr.fsf@gitster.siamese.dyndns.org>
Hi,
On Mon, 8 Sep 2008, Junio C Hamano wrote:
Show 42 quoted lines
> Dmitry Potapov <dpotapov@gmail.com> writes:
> 
> > If git rebase interactive is stopped by "edit" command and then the user
> > said "git rebase --continue" while having some stage changes, git rebase
> > interactive is trying to amend the last commit by doing:
> >   git --soft reset && git commit
> >
> > However, the user can abort commit for some reason by providing an empty
> > log message, and that would leave the last commit undone, while the user
> > being completely unaware about what happened. Now if the user tries to
> > continue, by issuing "git rebase --continue" that squashes two previous
> > commits.
> >
> > Signed-off-by: Dmitry Potapov <dpotapov@gmail.com>
> > ---
> >  git-rebase--interactive.sh |    7 +++++--
> >  1 files changed, 5 insertions(+), 2 deletions(-)
> >
> > diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
> > index 929d681..5b2b1e5 100755
> > --- a/git-rebase--interactive.sh
> > +++ b/git-rebase--interactive.sh
> > @@ -429,12 +429,15 @@ do
> >  				die "Cannot find the author identity"
> >  			if test -f "$DOTEST"/amend
> >  			then
> > +				amend=$(git rev-parse --verify HEAD)
> >  				git reset --soft HEAD^ ||
> >  				die "Cannot rewind the HEAD"
> >  			fi
> >  			export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE &&
> > -			git commit --no-verify -F "$DOTEST"/message -e ||
> > -			die "Could not commit staged changes."
> > +			git commit --no-verify -F "$DOTEST"/message -e || {
> > +				test -n "$amend" && git reset --soft $amend
> > +				die "Could not commit staged changes."
> > +			}
> >  		fi
> 
> Feels obviously correct from a cursory look, although I admit I haven't
> thought about other possible corner cases that this additional reset may
> fire when it shouldn't.  Dscho?

It might be safer to set the variable "amend" to empty before the "if". Other than that, I think that patch makes tons of sense.

Thanks, Dscho

Previous: Junio C HamanoNext: Dmitry Potapov
Message 9 of 12 in “git-rebase-interactive: do not squash commits on abort”
  1. 1/2 git-rebase-interactive: do not squash commits on abortDmitry Potapov, Sep 8, 2008
  2. 2/2 git-rebase--interactive: auto amend only edited commitDmitry Potapov, Sep 8, 2008
  3. Junio C HamanoSep 9, 2008
  4. Dmitry PotapovSep 9, 2008
  5. git-rebase--interactive: auto amend only edited commitDmitry Potapov, Sep 9, 2008
  6. Johannes SixtSep 9, 2008
  7. Dmitry PotapovSep 9, 2008
  8. Junio C HamanoSep 9, 2008
  9. Johannes SchindelinSep 9, 2008
  10. git-rebase-interactive: do not squash commits on abortDmitry Potapov, Sep 9, 2008
  11. Johannes SchindelinSep 10, 2008
  12. Junio C HamanoSep 10, 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.