git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ramkumar Ramachandra <artagnon@gmail.com>
To: Jeff King <peff@peff.net>
Cc: "SZEDER Gábor" <szeder@ira.uka.de>,
	"Christian Couder" <christian.couder@gmail.com>,
	"Christian Couder" <chriscool@tuxfamily.org>,
	git@vger.kernel.org, "Jonathan Nieder" <jrnieder@gmail.com>
Subject: [PATCH] cherry-pick: add failing test for out-of-order pick
Date: Thu, 12 Jan 2012 23:20:47 +0530	[thread overview]
Message-ID: <1326390647-21446-1-git-send-email-artagnon@gmail.com> (raw)
In-Reply-To: <CALkWK0nJM2wUE9qzp38qjFFqCdwX9w0Jckxi1G=1=7adMxg2rw@mail.gmail.com>

Due to the way traditional revision arguments work, the following
invocations of 'git cherry-pick' are equivalent:

  $ git cherry-pick master..topic
  $ git cherry-pick topic ^master
  $ git cherry-pick ^master topic

So the order of the arguments specified on the command-line is
irrelevant in these cases.  However, there are cases where it is worth
paying attention to the order.  For instance:

  $ git cherry-pick commit3 commit1 commit2

picks commits after sorting by date order, which is counter-intuitive.
Add a failing test to t3508 (cherry-pick-many-commits) documenting
this behavior.

Reported-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 Irrespective of how far we get with the '--literal-order' idea, I
 think this quirk is worth documenting.

 t/t3508-cherry-pick-many-commits.sh |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/t/t3508-cherry-pick-many-commits.sh b/t/t3508-cherry-pick-many-commits.sh
index 8e09fd0..dd65835 100755
--- a/t/t3508-cherry-pick-many-commits.sh
+++ b/t/t3508-cherry-pick-many-commits.sh
@@ -59,6 +59,31 @@ test_expect_success 'cherry-pick first..fourth works' '
 	check_head_differs_from fourth
 '
 
+test_expect_failure 'cherry-pick picks commits in the right order' '
+	cat <<-\EOF >expected &&
+	[master OBJID] fourth
+	 Author: A U Thor <author@example.com>
+	 1 files changed, 1 insertions(+), 0 deletions(-)
+	[master OBJID] second
+	 Author: A U Thor <author@example.com>
+	 1 files changed, 1 insertions(+), 0 deletions(-)
+	[master OBJID] third
+	 Author: A U Thor <author@example.com>
+	 1 files changed, 1 insertions(+), 0 deletions(-)
+	EOF
+
+	git checkout -f master &&
+	git reset --hard first &&
+	test_tick &&
+	git cherry-pick fourth second third >actual &&
+	git diff --quiet other &&
+	git diff --quiet HEAD other &&
+
+	sed -e "s/$_x05[0-9a-f][0-9a-f]/OBJID/" <actual >actual.fuzzy &&
+	test_cmp expected actual.fuzzy &&
+	check_head_differs_from second
+'
+
 test_expect_success 'cherry-pick --strategy resolve first..fourth works' '
 	cat <<-\EOF >expected &&
 	Trying simple merge.
-- 
1.7.8.2

  reply	other threads:[~2012-01-12 17:52 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-11 17:31 [BUG] multi-commit cherry-pick messes up the order of commits SZEDER Gábor
2012-01-12 13:31 ` Christian Couder
2012-01-12 14:44   ` SZEDER Gábor
2012-01-12 16:35     ` Ramkumar Ramachandra
2012-01-12 16:53     ` Jeff King
2012-01-12 17:09       ` Ramkumar Ramachandra
2012-01-12 17:14         ` Ramkumar Ramachandra
2012-01-12 17:15         ` Jeff King
2012-01-12 17:26           ` Ramkumar Ramachandra
2012-01-12 17:50             ` Ramkumar Ramachandra [this message]
2012-01-12 18:32               ` [PATCH] cherry-pick: add failing test for out-of-order pick Jonathan Nieder
2012-01-12 19:05                 ` [PATCH v2] " Ramkumar Ramachandra
2012-01-12 19:33                   ` Jonathan Nieder
2012-01-12 18:25         ` [BUG] multi-commit cherry-pick messes up the order of commits Junio C Hamano
2012-01-12 19:25           ` Ramkumar Ramachandra
2012-01-12 19:47             ` Jeff King
2012-01-12 20:11               ` Jonathan Nieder
2012-01-12 20:17                 ` Jeff King
2012-01-12 20:11             ` Junio C Hamano
2012-01-12 19:21         ` Johannes Sixt
2012-01-12 19:29           ` Ramkumar Ramachandra
2012-01-12 19:34             ` Jonathan Nieder
2012-01-12 17:47       ` Jonathan Nieder
2012-01-12 18:41         ` 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=1326390647-21446-1-git-send-email-artagnon@gmail.com \
    --to=artagnon@gmail.com \
    --cc=chriscool@tuxfamily.org \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=jrnieder@gmail.com \
    --cc=peff@peff.net \
    --cc=szeder@ira.uka.de \
    /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).