From: "SZEDER Gábor" <szeder@ira.uka.de>
To: Christian Couder <chriscool@tuxfamily.org>, <git@vger.kernel.org>
Subject: [BUG] multi-commit cherry-pick messes up the order of commits
Date: Wed, 11 Jan 2012 18:31:01 +0100 [thread overview]
Message-ID: <20120111173101.GQ30469@goldbirke> (raw)
Hi,
I did some multi-commit cherry-picks lately, and noticed that
sometimes cherry-pick applied the commits in different order than I
specified on the command line. After some debugging, today I could
finally come up with a receipe to reproduce:
git init
echo 1 >a && git add a
git commit -m a
echo 2 >b && git add b
git commit -m b
sleep 2 && echo 3 >c && git add c
git commit -m c
git checkout -b branch HEAD^^
git cherry-pick master master^ # the later commit first
where the 'git cherry-pick' command produces the following output:
[branch ef5b86e0] b
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 b
[branch 6a74f934] c
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 c
Notice that master^, i.e. the commit adding the file 'b', is picked
before master, i.e. the commit adding 'c', although the order on the
command line was the reverse.
This is because
cmd_cherry_pick()
pick_revisions()
walk_revs_populate_todo()
prepare_revs()
calls prepare_revision_walk(), which parses the commits from the
command line in the order they were specified, but inserts them into a
list ordered by date, and commits will be picked in the order they
appear in this list. So if you specify commits in a different order
than their committer date or commits with the same commiter date
(which are often produced by am, rebase, and multi-commit
cherry-pick), then they will be picked in wrong order.
As far as I can tell, this buggy behavior is as old as multi-commit
cherry-pick itself, i.e. 7e2bfd3f (revert: allow cherry-picking more
than one commit, 2010-06-02).
Best,
Gábor
next reply other threads:[~2012-01-11 17:40 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-11 17:31 SZEDER Gábor [this message]
2012-01-12 13:31 ` [BUG] multi-commit cherry-pick messes up the order of commits 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 ` [PATCH] cherry-pick: add failing test for out-of-order pick Ramkumar Ramachandra
2012-01-12 18:32 ` 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=20120111173101.GQ30469@goldbirke \
--to=szeder@ira.uka.de \
--cc=chriscool@tuxfamily.org \
--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