git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Nanako Shiraishi <nanako3@lavabit.com>
Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>,
	Michael J Gruber <git@drmicha.warpmail.net>,
	Michael Haggerty <mhagger@alum.mit.edu>,
	git@vger.kernel.org
Subject: Re: [PATCH 0/3] Add a "fix" command to "rebase --interactive"
Date: Tue, 08 Dec 2009 22:16:25 -0800	[thread overview]
Message-ID: <7vaaxsvfie.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <7viqchhl7h.fsf@alter.siamese.dyndns.org> (Junio C. Hamano's message of "Tue\, 08 Dec 2009 01\:24\:50 -0800")

Junio C Hamano <gitster@pobox.com> writes:

> Nanako Shiraishi <nanako3@lavabit.com> writes:
>
>> @@ -519,6 +521,43 @@ get_saved_options () {
>>  	test -f "$DOTEST"/rebase-root && REBASE_ROOT=t
>>  }
>>  
>> +# Rearrange the todo list that has both "pick sha1 msg" and
>> +# "pick sha1 !fixup/!squash msg" appears in it so that the latter
>> +# comes immediately after the former, and change "pick" to
>> +# "fixup"/"squash".
>> +rearrange_squash () {
>> +	sed -n -e 's/^pick \([0-9a-f]*\) !\(squash\) /\1 \2 /p' \
>> +		-e 's/^pick \([0-9a-f]*\) !\(fixup\) /\1 \2 /p' \
>> +		"$1" >"$1.sq"
>> +	test -s "$1.sq" || return
>> +
>> +	sed -e '/^pick [0-9a-f]* !squash /d' \
>> +		-e '/^pick [0-9a-f]* !fixup /d' \
>> +		"$1" |
>> +	(
>> +		used=
>> +		while read pick sha1 message
>> +		do
>> +	...
>> +		done >"$1.rearranged"
>> +	)
>> +	cat "$1.rearranged" >"$1"
>> +	rm -f "$1.sq"
>> +}
>
> The logic to move the lines seem to have been improved since the last
> round, which is good.  I've amended this to remove "$1.rearranged" as well.

Actually I think the logic in the version from the June is more correct;
doesn't this version drop commits that are marked as "squash! <message>"
but with a misspelled <message> part?  I think your old version, when it
didn't find a matching one in early part, left such an unmatched "fixup"
in place.

Here is a fix-up patch I think should be squashed in.  I added a test to
make sure that a mismatching "squash!" is kept in place.  Please double
check for sanity.

Thanks.

 git-rebase--interactive.sh   |   38 ++++++++++++++++----------------------
 t/t3415-rebase-autosquash.sh |   15 +++++++++++++++
 2 files changed, 31 insertions(+), 22 deletions(-)

diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index c68cc5b..935e9e1 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -531,29 +531,23 @@ rearrange_squash () {
 		"$1" >"$1.sq"
 	test -s "$1.sq" || return
 
-	sed -e '/^pick [0-9a-f]* squash! /d' \
-		-e '/^pick [0-9a-f]* fixup! /d' \
-		"$1" |
-	(
-		used=
-		while read pick sha1 message
+	used=
+	while read pick sha1 message
+	do
+		case " $used" in
+		*" $sha1 "*) continue ;;
+		esac
+		echo "$pick $sha1 $message"
+		while read squash action msg
 		do
-			echo "$pick $sha1 $message"
-			while read squash action msg
-			do
-				case " $used" in
-				*" $squash "*)
-					continue ;;
-				esac
-				case "$message" in
-				"$msg"*)
-					echo "$action $squash $action! $msg"
-					used="$used$squash "
-					;;
-				esac
-			done <"$1.sq"
-		done >"$1.rearranged"
-	)
+			case "$message" in
+			"$msg"*)
+				echo "$action $squash $action! $msg"
+				used="$used$squash "
+				;;
+			esac
+		done <"$1.sq"
+	done >"$1.rearranged" <"$1"
 	cat "$1.rearranged" >"$1"
 	rm -f "$1.sq" "$1.rearranged"
 }
diff --git a/t/t3415-rebase-autosquash.sh b/t/t3415-rebase-autosquash.sh
index f7a0f7a..b63f4e2 100755
--- a/t/t3415-rebase-autosquash.sh
+++ b/t/t3415-rebase-autosquash.sh
@@ -55,4 +55,19 @@ test_expect_success 'auto squash' '
 	test 2 = $(git cat-file commit HEAD^ | grep first | wc -l)
 '
 
+test_expect_success 'misspelled auto squash' '
+	git reset --hard base &&
+	echo 1 >file1 &&
+	git add -u &&
+	test_tick &&
+	git commit -m "squash! forst"
+	git tag final-missquash &&
+	test_tick &&
+	git rebase --autosquash -i HEAD^^^ &&
+	git log --oneline >actual &&
+	test 4 = $(wc -l <actual) &&
+	git diff --exit-code final-missquash &&
+	test 0 = $(git rev-list final-missquash...HEAD | wc -l)
+'
+
 test_done

  parent reply	other threads:[~2009-12-09  6:16 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-04 14:36 [PATCH 0/3] Add a "fix" command to "rebase --interactive" Michael Haggerty
2009-12-04 14:36 ` [PATCH 1/3] Better document the original repository layout Michael Haggerty
2009-12-04 14:52   ` Michael J Gruber
2009-12-04 16:51     ` Johannes Schindelin
2009-12-04 14:36 ` [PATCH 2/3] Set a couple more tags in the original repository Michael Haggerty
2009-12-04 16:52   ` Johannes Schindelin
2009-12-04 14:36 ` [PATCH 3/3] Add a command "fix" to rebase --interactive Michael Haggerty
2009-12-04 16:57   ` Johannes Schindelin
2009-12-04 17:40   ` Junio C Hamano
2009-12-04 17:44     ` Matthieu Moy
2009-12-04 18:44     ` Johannes Schindelin
2009-12-05 18:53       ` Junio C Hamano
2009-12-04 15:13 ` [PATCH 0/3] Add a "fix" command to "rebase --interactive" Michael J Gruber
2009-12-04 17:40   ` Matthieu Moy
2009-12-04 17:44     ` Junio C Hamano
2009-12-04 18:47       ` Johannes Schindelin
2009-12-04 21:27         ` Nanako Shiraishi
2009-12-05  7:39           ` Junio C Hamano
2009-12-08  3:13             ` [PATCH 0/3] Add a "fix" command to "rebase --interactive", [PATCH] rebase -i --autosquash: auto-squash commits Nanako Shiraishi
2009-12-08  3:28               ` [PATCH 0/3] Add a "fix" command to "rebase --interactive" Junio C Hamano
2009-12-08  6:01                 ` Nanako Shiraishi
2009-12-08  7:43                   ` Junio C Hamano
2009-12-08  9:24               ` Junio C Hamano
2009-12-08  9:35                 ` Jeff King
2009-12-08 13:51                   ` Sverre Rabbelier
2009-12-09  3:55                     ` Nanako Shiraishi
2009-12-09  4:41                       ` Aaron Cohen
2009-12-09  6:16                 ` Junio C Hamano [this message]
2009-12-08 14:39               ` Matthieu Moy
2009-12-04 15:50 ` Shawn O. Pearce
2009-12-04 22:19 ` Björn Gustavsson
2009-12-04 22:29   ` 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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=7vaaxsvfie.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=Matthieu.Moy@grenoble-inp.fr \
    --cc=git@drmicha.warpmail.net \
    --cc=git@vger.kernel.org \
    --cc=mhagger@alum.mit.edu \
    --cc=nanako3@lavabit.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).