git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Potapov <dpotapov@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 2/2] git-rebase--interactive: auto amend only edited commit
Date: Tue, 9 Sep 2008 11:00:55 +0400	[thread overview]
Message-ID: <20080909070055.GB28210@dpotapov.dyndns.org> (raw)
In-Reply-To: <7viqt6cg4t.fsf@gitster.siamese.dyndns.org>

On Mon, Sep 08, 2008 at 05:33:22PM -0700, Junio C Hamano wrote:
> I may not be reading your patch correctly; I am confused by what you are
> trying to do.
> 
> > diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
> > index 5b2b1e5..84721c9 100755
> > --- a/git-rebase--interactive.sh
> > +++ b/git-rebase--interactive.sh
> > @@ -284,7 +284,7 @@ do_next () {
> >  		pick_one $sha1 ||
> >  			die_with_patch $sha1 "Could not apply $sha1... $rest"
> >  		make_patch $sha1
> > -		: > "$DOTEST"/amend
> > +		echo $sha1 > "$DOTEST"/amend
> 
> You record the $sha1 from the TODO file.

Oops... I should have gone to bed instead of sending this patch...

> 
> Perhaps you wanted to record the value of the HEAD in the first hunk?

You are asbolutely right. It should be:

	git rev-parse --verify HEAD > "$DOTEST"/amend

> 
> How would this change interact with the workflow of splitting existing
> commits, described at the end of git-rebase documentation?

It is not affected, because accordingly to the documentation, you
commit all your changes "until your working tree is clean."

However, if you forgot to commit your changes, without my patch
you may lose some of your splitting work. Here is the script that
demonstrates the problem

-- >8 --
#!/bin/sh

set -e

rm -rf git-test
mkdir -p git-test
cd git-test

git init
for ((i=0;$i<10;i++)) do echo $i; done > foo
git add foo
git commit -m 'add foo'

sed -e 's/^0$/first line/;s/^9/last line/' < foo > tmp
mv tmp foo
git add foo
git commit -m 'change foo'

echo bar > bar
git add bar
git commit -m 'more changes'

git log
echo '==='

GIT_EDITOR='sed -e '\''s/pick \(.* change foo\)/edit \1/'\'' < "$1" > tmp && mv tmp' git rebase -i HEAD~2

git reset HEAD^

{ echo y; echo n; } | git add -p

git commit -m 'commit chunk 1'

git add foo
# If I commit chunk 2 then everything will be fine with and without
# my patch
#
#   git commit -m 'commit chunk 2'
#
# However, if I forgot to commit chunk 2 then without my patch rebase
# will lose my work on splitting these chunks!
#
# With my patch, it will error out: You have uncommitted changes

GIT_EDITOR=cat git rebase --continue

git log
-- >8 --


Dmitry

  reply	other threads:[~2008-09-09  7:02 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-08 20:42 [PATCH 1/2] git-rebase-interactive: do not squash commits on abort Dmitry Potapov
2008-09-08 20:42 ` [PATCH 2/2] git-rebase--interactive: auto amend only edited commit Dmitry Potapov
2008-09-09  0:33   ` Junio C Hamano
2008-09-09  7:00     ` Dmitry Potapov [this message]
2008-09-09 12:05       ` [PATCH v2] " Dmitry Potapov
2008-09-09  6:42   ` [PATCH 2/2] " Johannes Sixt
2008-09-09  7:30     ` Dmitry Potapov
2008-09-09  0:06 ` [PATCH 1/2] git-rebase-interactive: do not squash commits on abort Junio C Hamano
2008-09-09 14:17   ` Johannes Schindelin
2008-09-09 20:50     ` [PATCH v2] " Dmitry Potapov
2008-09-10  9:53       ` Johannes Schindelin
2008-09-10 22:36         ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080909070055.GB28210@dpotapov.dyndns.org \
    --to=dpotapov@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).