{"thread":{"id":"24104","subject":"[PATCH] revert: add --stdin option to read commits from stdin","startedAt":"2010-06-14T03:22:50Z","lastAt":"2010-06-15T03:28:05Z","messageCount":7,"participants":["Christian Couder","Jonathan Nieder","Johannes Sixt"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"143626","messageId":"20100614032251.20121.83253.chriscool@tuxfamily.org","threadId":"24104","inReplyTo":null,"subject":"[PATCH] revert: add --stdin option to read commits from stdin","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2010-06-14T03:22:50Z","receivedAt":"2010-06-14T03:22: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\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n\tThis applies on top of pu as it is related to my cherry-pick\n\tmany commits series.\n\n Documentation/git-cherry-pick.txt   |   14 +++++++++++++-\n Documentation/git-revert.txt        |    6 +++++-\n builtin/revert.c                    |    9 ++++++---\n t/t3508-cherry-pick-many-commits.sh |   10 ++++++++++\n 4 files changed, 34 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/git-cherry-pick.txt b/Documentation/git-cherry-pick.txt\nindex bcb4c75..54e6833 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] [--stdin]\n+\t\t<commit>...\n \n DESCRIPTION\n -----------\n@@ -79,6 +80,10 @@ effect to your index in a row.\n \tcherry-pick'ed commit, then a fast forward to this commit will\n \tbe performed.\n \n+--stdin::\n+\tIn addition to the '<commit>' listed on the command\n+\tline, read them from the standard input.\n+\n EXAMPLES\n --------\n git cherry-pick master::\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..84b4a68 100644\n--- a/Documentation/git-revert.txt\n+++ b/Documentation/git-revert.txt\n@@ -7,7 +7,7 @@ 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] [--stdin] <commit>...\n \n DESCRIPTION\n -----------\n@@ -80,6 +80,10 @@ effect to your index in a row.\n --signoff::\n \tAdd Signed-off-by line at the end of the commit message.\n \n+--stdin::\n+\tIn addition to the '<commit>' listed on the command\n+\tline, read them from the standard input.\n+\n EXAMPLES\n --------\n git revert HEAD~3::\ndiff --git a/builtin/revert.c b/builtin/revert.c\nindex 853e9e4..2b3d5a5 100644\n--- a/builtin/revert.c\n+++ b/builtin/revert.c\n@@ -41,7 +41,7 @@ static enum { REVERT, CHERRY_PICK } action;\n static struct commit *commit;\n static int commit_argc;\n static const char **commit_argv;\n-static int allow_rerere_auto;\n+static int allow_rerere_auto, read_stdin;\n \n static const char *me;\n static const char *strategy;\n@@ -63,6 +63,7 @@ static void parse_args(int argc, const char **argv)\n \t\tOPT_INTEGER('m', \"mainline\", &mainline, \"parent number\"),\n \t\tOPT_RERERE_AUTOUPDATE(&allow_rerere_auto),\n \t\tOPT_STRING(0, \"strategy\", &strategy, \"strategy\", \"merge strategy\"),\n+\t\tOPT_BOOLEAN(0, \"stdin\", &read_stdin, \"read commits from stdin\"),\n \t\tOPT_END(),\n \t\tOPT_END(),\n \t\tOPT_END(),\n@@ -79,7 +80,7 @@ static void parse_args(int argc, const char **argv)\n \t}\n \n \tcommit_argc = parse_options(argc, argv, NULL, options, usage_str, 0);\n-\tif (commit_argc < 1)\n+\tif (commit_argc < 1 && !read_stdin)\n \t\tusage_with_options(usage_str, options);\n \n \tcommit_argv = argv;\n@@ -527,10 +528,12 @@ static void prepare_revs(struct rev_info *revs)\n {\n \tint argc = 0;\n \tint i;\n-\tconst char **argv = xmalloc((commit_argc + 4) * sizeof(*argv));\n+\tconst char **argv = xmalloc((commit_argc + 5) * sizeof(*argv));\n \n \targv[argc++] = NULL;\n \targv[argc++] = \"--no-walk\";\n+\tif (read_stdin)\n+\t\targv[argc++] = \"--stdin\";\n \tif (action != REVERT)\n \t\targv[argc++] = \"--reverse\";\n \tfor (i = 0; i < commit_argc; i++)\ndiff --git a/t/t3508-cherry-pick-many-commits.sh b/t/t3508-cherry-pick-many-commits.sh\nindex 3b87efe..27096f1 100755\n--- a/t/t3508-cherry-pick-many-commits.sh\n+++ b/t/t3508-cherry-pick-many-commits.sh\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 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.468.g77401.dirty\n"},{"id":"143629","messageId":"20100614052027.GA1509@burratino","threadId":"24104","inReplyTo":"20100614032251.20121.83253.chriscool@tuxfamily.org","subject":"Re: [PATCH] revert: add --stdin option to read commits from stdin","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-06-14T05:20:27Z","receivedAt":"2010-06-14T05:20:27Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Christian Couder wrote:\n\n> --- a/t/t3508-cherry-pick-many-commits.sh\n> +++ b/t/t3508-cherry-pick-many-commits.sh\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 master &&\n> +\tgit reset --hard first &&\n[...]\n\nThis test fails for me as written, since the previous test leaves some\nfiles in an unmerged state.  Patch 1 below works around that.\n\n> --- a/builtin/revert.c\n> +++ b/builtin/revert.c\n> @@ -79,7 +80,7 @@ static void parse_args(int argc, const char **argv)\n>  \t}\n>  \n>  \tcommit_argc = parse_options(argc, argv, NULL, options, usage_str, 0);\n[...]\n> @@ -527,10 +528,12 @@ static void prepare_revs(struct rev_info *revs)\n>  {\n>  \tint argc = 0;\n>  \tint i;\n> -\tconst char **argv = xmalloc((commit_argc + 4) * sizeof(*argv));\n> +\tconst char **argv = xmalloc((commit_argc + 5) * sizeof(*argv));\n>  \n>  \targv[argc++] = NULL;\n>  \targv[argc++] = \"--no-walk\";\n> +\tif (read_stdin)\n> +\t\targv[argc++] = \"--stdin\";\n\nAh, I see the problem now.  But it would be even nicer to allow arbitrary\nrev-list options, so a person could ‘git cherry-pick --reverse a..b’,\nfor example.\n\nIn other words, how about something like patch 2 below?\n\nPatch 3 is a small cleanup, as a bonus.\n\nChristian Couder (1):\n  revert: accept arbitrary rev-list options\n\nJonathan Nieder (2):\n  t3508 (cherry-pick): futureproof against unmerged files\n  revert: do not rebuild argv on heap\n\n Documentation/git-cherry-pick.txt   |    7 ++++++\n builtin/revert.c                    |   37 ++++++++++++++++++-----------------\n t/t3501-revert-cherry-pick.sh       |   18 +++++++++++++++++\n t/t3508-cherry-pick-many-commits.sh |   24 ++++++++++++++++------\n 4 files changed, 61 insertions(+), 25 deletions(-)\n"},{"id":"143630","messageId":"20100614052850.GA1737@burratino","threadId":"24104","inReplyTo":"20100614052027.GA1509@burratino","subject":"[PATCH 1/3] t3508 (cherry-pick): futureproof against unmerged files","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-06-14T05:28:50Z","receivedAt":"2010-06-14T05:28:50Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Each of the tests in t3508 begins by navigating to a sane state:\n\n\tgit checkout master &&\n\tgit reset --hard $commit\n\nIf a previous test left unmerged files around, they are untouched and\nthe checkout fails, causing later tests to fail, too.  This is not a\nproblem in practice because no test except the final one produces\nunmerged files.\n\nBut as a futureproofing measure, it is still best to avoid the problem\nwith 'checkout -f'.  In particular, this is needed for new tests to be\nadded to the end of the script.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n t/t3508-cherry-pick-many-commits.sh |   14 +++++++-------\n 1 files changed, 7 insertions(+), 7 deletions(-)\n\ndiff --git a/t/t3508-cherry-pick-many-commits.sh b/t/t3508-cherry-pick-many-commits.sh\nindex 3b87efe..26a8730 100755\n--- a/t/t3508-cherry-pick-many-commits.sh\n+++ b/t/t3508-cherry-pick-many-commits.sh\n@@ -23,7 +23,7 @@ test_expect_success setup '\n '\n \n test_expect_success 'cherry-pick first..fourth works' '\n-\tgit checkout master &&\n+\tgit checkout -f master &&\n \tgit reset --hard first &&\n \ttest_tick &&\n \tgit cherry-pick first..fourth &&\n@@ -33,7 +33,7 @@ test_expect_success 'cherry-pick first..fourth works' '\n '\n \n test_expect_success 'cherry-pick --ff first..fourth works' '\n-\tgit checkout master &&\n+\tgit checkout -f master &&\n \tgit reset --hard first &&\n \ttest_tick &&\n \tgit cherry-pick --ff first..fourth &&\n@@ -43,7 +43,7 @@ test_expect_success 'cherry-pick --ff first..fourth works' '\n '\n \n test_expect_success 'cherry-pick -n first..fourth works' '\n-\tgit checkout master &&\n+\tgit checkout -f master &&\n \tgit reset --hard first &&\n \ttest_tick &&\n \tgit cherry-pick -n first..fourth &&\n@@ -53,7 +53,7 @@ test_expect_success 'cherry-pick -n first..fourth works' '\n '\n \n test_expect_success 'revert first..fourth works' '\n-\tgit checkout master &&\n+\tgit checkout -f master &&\n \tgit reset --hard fourth &&\n \ttest_tick &&\n \tgit revert first..fourth &&\n@@ -63,7 +63,7 @@ test_expect_success 'revert first..fourth works' '\n '\n \n test_expect_success 'revert ^first fourth works' '\n-\tgit checkout master &&\n+\tgit checkout -f master &&\n \tgit reset --hard fourth &&\n \ttest_tick &&\n \tgit revert ^first fourth &&\n@@ -73,7 +73,7 @@ test_expect_success 'revert ^first fourth works' '\n '\n \n test_expect_success 'revert fourth fourth~1 fourth~2 works' '\n-\tgit checkout master &&\n+\tgit checkout -f master &&\n \tgit reset --hard fourth &&\n \ttest_tick &&\n \tgit revert fourth fourth~1 fourth~2 &&\n@@ -83,7 +83,7 @@ test_expect_success 'revert fourth fourth~1 fourth~2 works' '\n '\n \n test_expect_failure 'cherry-pick -3 fourth works' '\n-\tgit checkout master &&\n+\tgit checkout -f master &&\n \tgit reset --hard first &&\n \ttest_tick &&\n \tgit cherry-pick -3 fourth &&\n-- \n1.7.1.246.g398e5.dirty\n"},{"id":"143631","messageId":"20100614052938.GB1737@burratino","threadId":"24104","inReplyTo":"20100614052027.GA1509@burratino","subject":"[PATCH 2/3] revert: accept arbitrary rev-list options","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-06-14T05:29:38Z","receivedAt":"2010-06-14T05:29:38Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"From: Christian Couder <chriscool@tuxfamily.org>\n\nThis can be useful to do something like:\n\ngit rev-list --reverse master -- README | git cherry-pick -n --stdin\n\nwithout using xargs.\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n Documentation/git-cherry-pick.txt   |    7 +++++++\n builtin/revert.c                    |    3 ++-\n t/t3508-cherry-pick-many-commits.sh |   10 ++++++++++\n 3 files changed, 19 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/git-cherry-pick.txt b/Documentation/git-cherry-pick.txt\nindex bcb4c75..f047739 100644\n--- a/Documentation/git-cherry-pick.txt\n+++ b/Documentation/git-cherry-pick.txt\n@@ -113,6 +113,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/builtin/revert.c b/builtin/revert.c\nindex 853e9e4..67e191b 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                            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..93d7189 100755\n--- a/t/t3508-cherry-pick-many-commits.sh\n+++ b/t/t3508-cherry-pick-many-commits.sh\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.246.g398e5.dirty\n"},{"id":"143632","messageId":"20100614053209.GC1737@burratino","threadId":"24104","inReplyTo":"20100614052027.GA1509@burratino","subject":"[PATCH 3/3] revert: do not rebuild argv on heap","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-06-14T05:32:09Z","receivedAt":"2010-06-14T05:32:09Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Set options in struct rev_info directly so we can reuse the\narguments collected from parse_options without modification.\n\nThis is just a cleanup; no noticeable change is intended.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nThanks, Christian.\n\n builtin/revert.c              |   34 +++++++++++++++++-----------------\n t/t3501-revert-cherry-pick.sh |   18 ++++++++++++++++++\n 2 files changed, 35 insertions(+), 17 deletions(-)\n\ndiff --git a/builtin/revert.c b/builtin/revert.c\nindex 67e191b..88b7501 100644\n--- a/builtin/revert.c\n+++ b/builtin/revert.c\n@@ -50,10 +50,14 @@ static const char *strategy;\n \n static char *get_encoding(const char *message);\n \n+static const char * const *revert_or_cherry_pick_usage(void)\n+{\n+\treturn action == REVERT ? revert_usage : cherry_pick_usage;\n+}\n+\n static void parse_args(int argc, const char **argv)\n {\n-\tconst char * const * usage_str =\n-\t\taction == REVERT ?  revert_usage : cherry_pick_usage;\n+\tconst char * const * usage_str = revert_or_cherry_pick_usage();\n \tint noop;\n \tstruct option options[] = {\n \t\tOPT_BOOLEAN('n', \"no-commit\", &no_commit, \"don't automatically commit\"),\n@@ -79,8 +83,9 @@ static void parse_args(int argc, const char **argv)\n \t}\n \n \tcommit_argc = parse_options(argc, argv, NULL, options, usage_str,\n+\t                            PARSE_OPT_KEEP_ARGV0 |\n \t                            PARSE_OPT_KEEP_UNKNOWN);\n-\tif (commit_argc < 1)\n+\tif (commit_argc < 2)\n \t\tusage_with_options(usage_str, options);\n \n \tcommit_argv = argv;\n@@ -526,27 +531,22 @@ static int do_pick_commit(void)\n \n static void prepare_revs(struct rev_info *revs)\n {\n-\tint argc = 0;\n-\tint i;\n-\tconst char **argv = xmalloc((commit_argc + 4) * sizeof(*argv));\n-\n-\targv[argc++] = NULL;\n-\targv[argc++] = \"--no-walk\";\n-\tif (action != REVERT)\n-\t\targv[argc++] = \"--reverse\";\n-\tfor (i = 0; i < commit_argc; i++)\n-\t\targv[argc++] = commit_argv[i];\n-\targv[argc++] = NULL;\n+\tint argc;\n \n \tinit_revisions(revs, NULL);\n-\tsetup_revisions(argc - 1, argv, revs, NULL);\n+\trevs->no_walk = 1;\n+\tif (action != REVERT)\n+\t\trevs->reverse = 1;\n+\n+\targc = setup_revisions(commit_argc, commit_argv, revs, NULL);\n+\tif (argc > 1)\n+\t\tusage(*revert_or_cherry_pick_usage());\n+\n \tif (prepare_revision_walk(revs))\n \t\tdie(\"revision walk setup failed\");\n \n \tif (!revs->commits)\n \t\tdie(\"empty commit set passed\");\n-\n-\tfree(argv);\n }\n \n static int revert_or_cherry_pick(int argc, const char **argv)\ndiff --git a/t/t3501-revert-cherry-pick.sh b/t/t3501-revert-cherry-pick.sh\nindex 7f85815..f61c54d 100755\n--- a/t/t3501-revert-cherry-pick.sh\n+++ b/t/t3501-revert-cherry-pick.sh\n@@ -41,6 +41,24 @@ test_expect_success setup '\n \tgit tag rename2\n '\n \n+test_expect_success 'cherry-pick --nonsense' '\n+\n+\tpos=$(git rev-parse HEAD) &&\n+\tgit diff --exit-code HEAD &&\n+\ttest_must_fail git cherry-pick --nonsense 2>msg &&\n+\tgit diff --exit-code HEAD \"$pos\" &&\n+\tgrep '[Uu]sage:' msg\n+'\n+\n+test_expect_success 'revert --nonsense' '\n+\n+\tpos=$(git rev-parse HEAD) &&\n+\tgit diff --exit-code HEAD &&\n+\ttest_must_fail git revert --nonsense 2>msg &&\n+\tgit diff --exit-code HEAD \"$pos\" &&\n+\tgrep '[Uu]sage:' msg\n+'\n+\n test_expect_success 'cherry-pick after renaming branch' '\n \n \tgit checkout rename2 &&\n-- \n1.7.1.246.g398e5.dirty\n"},{"id":"143637","messageId":"4C15CA3B.3050908@viscovery.net","threadId":"24104","inReplyTo":"20100614032251.20121.83253.chriscool@tuxfamily.org","subject":"Re: [PATCH] revert: add --stdin option to read commits from stdin","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2010-06-14T06:20:43Z","receivedAt":"2010-06-14T06:20:43Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 6/14/2010 5:22, schrieb Christian Couder:\n> +--stdin::\n> +\tIn addition to the '<commit>' listed on the command\n> +\tline, read them from the standard input.\n\nAnd the order in which --stdin and command line commits are processed is...?\n\n-- Hannes\n"},{"id":"143714","messageId":"201006150528.05265.chriscool@tuxfamily.org","threadId":"24104","inReplyTo":"20100614052027.GA1509@burratino","subject":"Re: [PATCH] revert: add --stdin option to read commits from stdin","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2010-06-15T03:28:05Z","receivedAt":"2010-06-15T03:28:05Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Monday 14 June 2010 07:20:27 Jonathan Nieder wrote:\n> Christian Couder wrote:\n> > --- a/t/t3508-cherry-pick-many-commits.sh\n> > +++ b/t/t3508-cherry-pick-many-commits.sh\n> > @@ -92,4 +92,14 @@ test_expect_failure 'cherry-pick -3 fourth works' '\n> >  \ttest \"$(git rev-parse --verify HEAD)\" != \"$(git rev-parse --verify\n> > fourth)\" '\n> >\n> > +test_expect_success 'cherry-pick --stdin works' '\n> > +\tgit checkout master &&\n> > +\tgit reset --hard first &&\n> \n> [...]\n> \n> This test fails for me as written, since the previous test leaves some\n> files in an unmerged state.  Patch 1 below works around that.\n\nOk.\n\n> > --- a/builtin/revert.c\n> > +++ b/builtin/revert.c\n> > @@ -79,7 +80,7 @@ static void parse_args(int argc, const char **argv)\n> >  \t}\n> >\n> >  \tcommit_argc = parse_options(argc, argv, NULL, options, usage_str, 0);\n> \n> [...]\n> \n> > @@ -527,10 +528,12 @@ static void prepare_revs(struct rev_info *revs)\n> >  {\n> >  \tint argc = 0;\n> >  \tint i;\n> > -\tconst char **argv = xmalloc((commit_argc + 4) * sizeof(*argv));\n> > +\tconst char **argv = xmalloc((commit_argc + 5) * sizeof(*argv));\n> >\n> >  \targv[argc++] = NULL;\n> >  \targv[argc++] = \"--no-walk\";\n> > +\tif (read_stdin)\n> > +\t\targv[argc++] = \"--stdin\";\n> \n> Ah, I see the problem now.  But it would be even nicer to allow arbitrary\n> rev-list options, so a person could ‘git cherry-pick --reverse a..b’,\n> for example.\n\nYeah, I agree that is nicer.\n\n> In other words, how about something like patch 2 below?\n> \n> Patch 3 is a small cleanup, as a bonus.\n> \n> Christian Couder (1):\n>   revert: accept arbitrary rev-list options\n> \n> Jonathan Nieder (2):\n>   t3508 (cherry-pick): futureproof against unmerged files\n>   revert: do not rebuild argv on heap\n\nI get \"indent with spaces\" errors when I apply patches 2/3 and 3/3:\n\n$ git am ../messages/\\[PATCH\\ 2_3\\]\\ revert_\\ accept\\ arbitrary\\ rev-list\\ \noptions.mbox\nApplying: revert: accept arbitrary rev-list options                                                                      \n/home/christian/work/git/.git/rebase-apply/patch:35: indent with spaces.                                                 \n                                    PARSE_OPT_KEEP_UNKNOWN);  \n\n$ git am ../messages/\\[PATCH\\ 3_3\\]\\ revert_\\ do\\ not\\ rebuild\\ argv\\ on\\ \nheap.mbox\nApplying: revert: do not rebuild argv on heap                                                                        \n/home/christian/work/git/.git/rebase-apply/patch:33: indent with spaces.                                             \n                                    PARSE_OPT_KEEP_ARGV0 |                                                           \nwarning: 1 line adds whitespace errors.\n\nBut otherwise it all looks very good to me.\n\nEven something like \"git cherry-pick -3 fourth\" is now working after patch \n2/3, so all test cases now pass. This is because \"--no-walk\" does not always \ntake over \"-3\" it looks like it depends on the order of the arguments.\n\nFor example I get:\n\n$ git rev-list --no-walk -3 --reverse fourth\n453a04748224b3f212580d1195b452334d346e75\ne85abe28a2b8ef771f760575b325f4c41f9c815f\n94d3184b3f0dcfebb393faf5a122dc429d775538\n\nbut:\n\n$ git rev-list -3 --no-walk --reverse fourth\n94d3184b3f0dcfebb393faf5a122dc429d775538\n\nI will post an updated v2 series without the whitespace errors and with a few \ndocumentation and test updates in patch 2/3.\n\nThanks,\nChristian.\n"}]}