[PATCH] cherry-pick: add failing test for out-of-order pick
- From
Ramkumar Ramachandra <artagnon@gmail.com>
- Date
- Jan 12, 2012, 17:50 UTC
- Message-ID
- <1326390647-21446-1-git-send-email-artagnon@gmail.com>
- 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