From: Kevin Ballard <kevin@sb.org>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
Sverre Rabbelier <srabbelier@gmail.com>,
Kevin Ballard <kevin@sb.org>
Subject: [PATCHv2 1/2] rebase: better rearranging of fixup!/squash! lines with --autosquash
Date: Thu, 4 Nov 2010 15:36:31 -0700 [thread overview]
Message-ID: <1288910192-10247-1-git-send-email-kevin@sb.org> (raw)
In-Reply-To: <7vr5f0vrbn.fsf@alter.siamese.dyndns.org>
The current behvaior of --autosquash can duplicate fixup!/squash! lines
if they match multiple commits, and it can also apply them to commits
that come after them in the todo list. Even more oddly, a commit that
looks like "fixup! fixup!" will match itself and be duplicated in the
todo list.
Change the todo list rearranging to mark all commits as used as soon
as they are emitted, and to avoid emitting a fixup/squash commit if the
commit has already been marked as used.
Signed-off-by: Kevin Ballard <kevin@sb.org>
---
This patch is unchanged from the previous version.
git-rebase--interactive.sh | 4 +++
t/t3415-rebase-autosquash.sh | 43 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+), 0 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index a27952d..379bbac 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -687,8 +687,12 @@ rearrange_squash () {
*" $sha1 "*) continue ;;
esac
printf '%s\n' "$pick $sha1 $message"
+ used="$used$sha1 "
while read -r squash action msg
do
+ case " $used" in
+ *" $squash "*) continue ;;
+ esac
case "$message" in
"$msg"*)
printf '%s\n' "$action $squash $action! $msg"
diff --git a/t/t3415-rebase-autosquash.sh b/t/t3415-rebase-autosquash.sh
index fd2184c..712bbe8 100755
--- a/t/t3415-rebase-autosquash.sh
+++ b/t/t3415-rebase-autosquash.sh
@@ -94,4 +94,47 @@ test_expect_success 'misspelled auto squash' '
test 0 = $(git rev-list final-missquash...HEAD | wc -l)
'
+test_expect_success 'auto squash that matches 2 commits' '
+ git reset --hard base &&
+ echo 4 >file4 &&
+ git add file4 &&
+ test_tick &&
+ git commit -m "first new commit" &&
+ echo 1 >file1 &&
+ git add -u &&
+ test_tick &&
+ git commit -m "squash! first" &&
+ git tag final-multisquash &&
+ test_tick &&
+ git rebase --autosquash -i HEAD~4 &&
+ git log --oneline >actual &&
+ test 4 = $(wc -l <actual) &&
+ git diff --exit-code final-multisquash &&
+ test 1 = "$(git cat-file blob HEAD^^:file1)" &&
+ test 2 = $(git cat-file commit HEAD^^ | grep first | wc -l) &&
+ test 1 = $(git cat-file commit HEAD | grep first | wc -l)
+'
+
+test_expect_success 'auto squash that matches a commit after the squash' '
+ git reset --hard base &&
+ echo 1 >file1 &&
+ git add -u &&
+ test_tick &&
+ git commit -m "squash! third" &&
+ echo 4 >file4 &&
+ git add file4 &&
+ test_tick &&
+ git commit -m "third commit" &&
+ git tag final-presquash &&
+ test_tick &&
+ git rebase --autosquash -i HEAD~4 &&
+ git log --oneline >actual &&
+ test 5 = $(wc -l <actual) &&
+ git diff --exit-code final-presquash &&
+ test 0 = "$(git cat-file blob HEAD^^:file1)" &&
+ test 1 = "$(git cat-file blob HEAD^:file1)" &&
+ test 1 = $(git cat-file commit HEAD | grep third | wc -l) &&
+ test 1 = $(git cat-file commit HEAD^ | grep third | wc -l)
+'
+
test_done
--
1.7.3.2.202.g3b863.dirty
next prev parent reply other threads:[~2010-11-04 22:36 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-04 2:41 [PATCH 1/2] rebase: better rearranging of fixup!/squash! lines with --autosquash Kevin Ballard
2010-11-04 2:41 ` [PATCH 2/2] rebase: teach --autosquash to match on sha1 in addition to message Kevin Ballard
2010-11-04 4:49 ` Kevin Ballard
2010-11-04 10:44 ` Sverre Rabbelier
2010-11-04 21:35 ` Kevin Ballard
2010-11-04 19:09 ` Junio C Hamano
2010-11-04 22:36 ` Kevin Ballard [this message]
2010-11-04 22:36 ` [PATCHv2 " Kevin Ballard
2010-11-05 13:04 ` [PATCH " Peter Krefting
2010-11-08 10:48 ` [PATCHv3 1/2] rebase: better rearranging of fixup!/squash! lines with --autosquash Kevin Ballard
2010-11-08 10:52 ` Yann Dirson
2010-11-08 11:10 ` Kevin Ballard
2010-11-08 10:48 ` [PATCHv3 2/2] rebase: teach --autosquash to match on sha1 in addition to message Kevin Ballard
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=1288910192-10247-1-git-send-email-kevin@sb.org \
--to=kevin@sb.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=srabbelier@gmail.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).