From: Greg Price <price@ksplice.com>
To: Johannes Sixt <j.sixt@viscovery.net>
Cc: Junio C Hamano <gitster@pobox.com>,
git@vger.kernel.org, Stephen Haberman <stephen@exigencecorp.com>
Subject: Re: [PATCH] Fix rebase -p --onto
Date: Fri, 17 Jul 2009 12:48:46 -0400 [thread overview]
Message-ID: <20090717164845.GL7878@vinegar-pot.mit.edu> (raw)
In-Reply-To: <4A6038E8.1090402@viscovery.net>
On Fri, Jul 17, 2009 at 10:40:08AM +0200, Johannes Sixt wrote:
> I have used rebase -i -p in the past to rewrite history that involves
> merges of topic branches like this:
>
> ---------Y--M--M--F <-- master
> / /
> ----a--a--a /
> /
> --b--b--b--b
>
> where F is a fixup that I want to insert between Y and M, and I thought
> rebase -i -p was intended for this use-case.
I don't believe rebase -i -p has ever worked with reordering commits.
It certainly doesn't now, as the tests below demonstrate both for your
case and for the most trivial possible situation without even any merges.
This is not a mere coding error, as in the general case with a hairy
set of merges it's not clear what an arbitrary reordering of the
commits would even mean. To really fix it will require a richer TODO
file format, as in the sequencer or the discussion Johannes Schindelin
started in January about a rebase -i -p rework.
In any case, this has nothing to do with my patch to fix -p --onto,
which is a no-op when --onto is not used. You want `git rebase -i -p Y`,
and the generation of the TODO file correctly gives you M, M, F.
It's the execution of the TODO file you give back, with F, M, M,
that does not do what you want.
Cheers,
Greg
>From 185fa9da4caee5a0a96105e60269d02ec832e876 Mon Sep 17 00:00:00 2001
From: Greg Price <price@ksplice.com>
Date: Fri, 17 Jul 2009 11:55:11 -0400
Subject: [PATCH] Add failing test for commit reordering in rebase -i -p
Signed-off-by: Greg Price <price@ksplice.com>
---
t/t3411-rebase-preserve-around-merges.sh | 59 ++++++++++++++++++++++++++++++
1 files changed, 59 insertions(+), 0 deletions(-)
diff --git a/t/t3411-rebase-preserve-around-merges.sh b/t/t3411-rebase-preserve-around-merges.sh
index 6533505..1759a98 100755
--- a/t/t3411-rebase-preserve-around-merges.sh
+++ b/t/t3411-rebase-preserve-around-merges.sh
@@ -71,4 +71,63 @@ test_expect_success 'rebase two levels of merge' '
test "$(git rev-parse HEAD^2^1^1)" = "$(git rev-parse HEAD^2^2^1)"
'
+# Reorder commits while using -p. Basic prerequisite for the next test
+# to have a hope of working.
+#
+# a---b---c
+#
+# want
+#
+# a---c---b
+
+test_expect_failure 'reorder with -p' '
+ test_commit a &&
+ test_commit b &&
+ test_commit c &&
+ FAKE_LINES="2 1" git rebase -i -p HEAD~2 &&
+ test "$(git rev-parse HEAD~2)" = "$(git rev-parse a)" &&
+ git log -n1 --pretty=format:%s HEAD | grep b &&
+ git log -n1 --pretty=format:%s HEAD^ | grep c
+'
+
+
+# Reorder a commit to before a merge. From
+#
+# R---x---Ma--Mb--F
+# \ / /
+# a1--a2 /
+# \ /
+# b1--b2
+#
+# we get
+#
+# R---x---F*--Ma*--Mb*
+# \ / /
+# a1--a2--/ /
+# \ /
+# b1--b2---/
+
+test_expect_failure 'rewrite to before merge' '
+ test_commit R &&
+ test_commit a1 &&
+ test_commit b1 &&
+ test_commit b2 &&
+ git reset --hard a1 &&
+ test_commit a2 &&
+ git reset --hard R &&
+ test_commit x &&
+ test_merge Ma a2 &&
+ test_merge Mb b2 &&
+ test_commit F &&
+
+ FAKE_LINES="3 1 2" git rebase -i -p x &&
+ git log --pretty=oneline HEAD && echo &&
+ git log --pretty=oneline HEAD^2 && echo &&
+ git log --pretty=oneline HEAD^^2 && echo &&
+ git log --pretty=oneline HEAD^^ && echo &&
+ test "$(git rev-parse HEAD^2)" = "$(git rev-parse b2)" &&
+ test "$(git rev-parse HEAD^1^2)" = "$(git rev-parse a2)" &&
+ test "$(git rev-parse HEAD~3)" = "$(git rev-parse x)"
+'
+
test_done
--
1.6.3.1.499.ge7b8da
next prev parent reply other threads:[~2009-07-17 16:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-16 23:00 [PATCH] Fix rebase -p --onto Greg Price
2009-07-17 6:38 ` Johannes Sixt
2009-07-17 8:27 ` Junio C Hamano
2009-07-17 8:40 ` Johannes Sixt
2009-07-17 8:47 ` Johannes Sixt
2009-07-17 16:48 ` Greg Price [this message]
2009-07-17 18:32 ` Johannes Schindelin
2009-07-17 19:00 ` Greg Price
2009-07-17 16:33 ` Greg Price
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=20090717164845.GL7878@vinegar-pot.mit.edu \
--to=price@ksplice.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=j.sixt@viscovery.net \
--cc=stephen@exigencecorp.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).