git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Dmitry Potapov <dpotapov@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 2/2] git-rebase--interactive: auto amend only edited commit
Date: Mon, 08 Sep 2008 17:33:22 -0700	[thread overview]
Message-ID: <7viqt6cg4t.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <1220906569-26878-2-git-send-email-dpotapov@gmail.com> (Dmitry Potapov's message of "Tue, 9 Sep 2008 00:42:49 +0400")

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.  If you are editing the first one
in the insn sequence, that is also the same as HEAD (i.e. the commit you
are telling the user to modify with "commit --amend").  If you already
have edited earlier ones, it is not the value of HEAD at this point.

>  		warn "Stopped at $sha1... $rest"
>  		warn "You can amend the commit now, with"
>  		warn
> @@ -430,6 +430,8 @@ do
>  			if test -f "$DOTEST"/amend
>  			then
>  				amend=$(git rev-parse --verify HEAD)
> +				test "$amend" = $(cat "$DOTEST"/amend) ||
> +				die "You have uncommitted changes"

And then you complain if HEAD, after running "commit --amend", is
not the value you recorded above.

>  				git reset --soft HEAD^ ||
>  				die "Cannot rewind the HEAD"
>  			fi

If the first commit was marked as "edit", then the value you recorded in
"$DOTEST/amend" was the HEAD, the commit the user was told to modify with
"commit --amend".  $DOTEST/amend being the same as HEAD here would be a
sign that the user staged changes but hasn't done "commit --amend".

But if we think about the second and subsequent commits that are marked as
"edit" in TODO file, the value recorded in "$DOTEST/amend" would not be
the value of HEAD at this point, and whether "commit --amend" has been run
or not, the value of HEAD is very likely to be different from that value
(unless the user said "reset --hard $that_one").  Wouldn't this test
almost always complain for them?

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

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

  reply	other threads:[~2008-09-09  0:35 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 [this message]
2008-09-09  7:00     ` Dmitry Potapov
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=7viqt6cg4t.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=dpotapov@gmail.com \
    --cc=git@vger.kernel.org \
    /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).