{"thread":{"id":"24114","subject":"[PATCH v2 2/3] revert: accept arbitrary rev-list options","startedAt":"2010-06-15T03:29:50Z","lastAt":"2010-06-15T03:29:50Z","messageCount":1,"participants":["Christian Couder"],"isPatch":true,"patchVersion":2,"patchTotal":3},"messages":[{"id":"143716","messageId":"20100615032952.3977.84899.chriscool@tuxfamily.org","threadId":"24114","inReplyTo":null,"subject":"[PATCH v2 2/3] revert: accept arbitrary rev-list options","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2010-06-15T03:29:50Z","receivedAt":"2010-06-15T03:29:50Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"This can be useful to do something like:\n\ngit rev-list --reverse master -- README | git cherry-pick -n --stdin\n\nwithout using xargs.\n\nAs an added bonus it makes \"git cherry-pick -3 fourth\" work.\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n Documentation/git-cherry-pick.txt   |   14 +++++++++++++-\n Documentation/git-revert.txt        |    7 ++++++-\n builtin/revert.c                    |    3 ++-\n t/t3508-cherry-pick-many-commits.sh |   12 +++++++++++-\n 4 files changed, 32 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/git-cherry-pick.txt b/Documentation/git-cherry-pick.txt\nindex bcb4c75..0711efd 100644\n--- a/Documentation/git-cherry-pick.txt\n+++ b/Documentation/git-cherry-pick.txt\n@@ -7,7 +7,8 @@ git-cherry-pick - Apply the changes introduced by some existing commits\n \n SYNOPSIS\n --------\n-'git cherry-pick' [--edit] [-n] [-m parent-number] [-s] [-x] [--ff] <commit>...\n+'git cherry-pick' [--edit] [-n] [-m parent-number] [-s] [-x] [--ff]\n+\t\t[<rev-list-options>] <commit>...\n \n DESCRIPTION\n -----------\n@@ -26,6 +27,10 @@ OPTIONS\n \tdefault, as if the '--no-walk' option was specified, see\n \tlinkgit:git-rev-list[1].\n \n+<rev-list-options>::\n+\tUnrecognized options are used as options to list commits, see\n+\tlinkgit:git-rev-list[1].\n+\n -e::\n --edit::\n \tWith this option, 'git cherry-pick' will let you edit the commit\n@@ -113,6 +118,13 @@ git cherry-pick --ff ..next::\n \tare in next but not HEAD to the current branch, creating a new\n \tcommit for each new change.\n \n+git rev-list --reverse master -- README | git cherry-pick -n --stdin::\n+\n+\tApply the changes introduced by all commits on the master\n+\tbranch that touched README to the working tree and index,\n+\tso the result can be inspected and made into a single new\n+\tcommit if suitable.\n+\n Author\n ------\n Written by Junio C Hamano <gitster@pobox.com>\ndiff --git a/Documentation/git-revert.txt b/Documentation/git-revert.txt\nindex dea4f53..e5f129e 100644\n--- a/Documentation/git-revert.txt\n+++ b/Documentation/git-revert.txt\n@@ -7,7 +7,8 @@ git-revert - Revert some existing commits\n \n SYNOPSIS\n --------\n-'git revert' [--edit | --no-edit] [-n] [-m parent-number] [-s] <commit>...\n+'git revert' [--edit | --no-edit] [-n] [-m parent-number] [-s]\n+\t\t[<rev-list-options>] <commit>...\n \n DESCRIPTION\n -----------\n@@ -36,6 +37,10 @@ OPTIONS\n \tdefault, see linkgit:git-rev-list[1] and its '--no-walk'\n \toption.\n \n+<rev-list-options>::\n+\tUnrecognized options are used as options to list commits, see\n+\tlinkgit:git-rev-list[1].\n+\n -e::\n --edit::\n \tWith this option, 'git revert' will let you edit the commit\ndiff --git a/builtin/revert.c b/builtin/revert.c\nindex 853e9e4..3f4a20e 100644\n--- a/builtin/revert.c\n+++ b/builtin/revert.c\n@@ -78,7 +78,8 @@ static void parse_args(int argc, const char **argv)\n \t\t\tdie(\"program error\");\n \t}\n \n-\tcommit_argc = parse_options(argc, argv, NULL, options, usage_str, 0);\n+\tcommit_argc = parse_options(argc, argv, NULL, options, usage_str,\n+\t\t\t\t    PARSE_OPT_KEEP_UNKNOWN);\n \tif (commit_argc < 1)\n \t\tusage_with_options(usage_str, options);\n \ndiff --git a/t/t3508-cherry-pick-many-commits.sh b/t/t3508-cherry-pick-many-commits.sh\nindex 26a8730..f90ed3d 100755\n--- a/t/t3508-cherry-pick-many-commits.sh\n+++ b/t/t3508-cherry-pick-many-commits.sh\n@@ -82,7 +82,7 @@ test_expect_success 'revert fourth fourth~1 fourth~2 works' '\n \tgit diff --quiet HEAD first\n '\n \n-test_expect_failure 'cherry-pick -3 fourth works' '\n+test_expect_success 'cherry-pick -3 fourth works' '\n \tgit checkout -f master &&\n \tgit reset --hard first &&\n \ttest_tick &&\n@@ -92,4 +92,14 @@ test_expect_failure 'cherry-pick -3 fourth works' '\n \ttest \"$(git rev-parse --verify HEAD)\" != \"$(git rev-parse --verify fourth)\"\n '\n \n+test_expect_success 'cherry-pick --stdin works' '\n+\tgit checkout -f master &&\n+\tgit reset --hard first &&\n+\ttest_tick &&\n+\tgit rev-list --reverse first..fourth | git cherry-pick --stdin &&\n+\tgit diff --quiet other &&\n+\tgit diff --quiet HEAD other &&\n+\ttest \"$(git rev-parse --verify HEAD)\" != \"$(git rev-parse --verify fourth)\"\n+'\n+\n test_done\n-- \n1.7.1.530.g14dc.dirty\n"}]}