{"thread":{"id":"23937","subject":"[RFC/PATCH 3/4] revert: allow cherry-picking a range of commits","startedAt":"2010-05-29T04:40:39Z","lastAt":"2010-06-01T03:12:49Z","messageCount":15,"participants":["Christian Couder","Sverre Rabbelier","Junio C Hamano","Johannes Schindelin","Ramkumar Ramachandra","Jonathan Nieder"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"142523","messageId":"20100529043738.569.85482.chriscool@tuxfamily.org","threadId":"23937","inReplyTo":null,"subject":"[RFC/PATCH 0/4] implement \"git cherry-pick A..B\"","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2010-05-29T04:40:39Z","receivedAt":"2010-05-29T04:40:39Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"This an RFC patch series to implement \"git cherry-pick A..B\" and\n\"git revert A..B\".\n\nThere is no documentation yet, and there is no way to continue or\nabort the process when cherry-picking fails.\n\nChristian Couder (4):\n  revert: use run_command_v_opt() instead of execv_git_cmd()\n  revert: refactor code into a do_pick_commit() function\n  revert: allow cherry-picking a range of commits\n  revert: add tests to check cherry-picking a range of commits\n\n builtin/revert.c             |   97 +++++++++++++++++++++++++++++-------------\n t/t3508-cherry-pick-range.sh |   65 ++++++++++++++++++++++++++++\n 2 files changed, 132 insertions(+), 30 deletions(-)\n create mode 100755 t/t3508-cherry-pick-range.sh\n"},{"id":"142521","messageId":"20100529044044.569.15379.chriscool@tuxfamily.org","threadId":"23937","inReplyTo":"20100529043738.569.85482.chriscool@tuxfamily.org","subject":"[RFC/PATCH 1/4] revert: use run_command_v_opt() instead of execv_git_cmd()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2010-05-29T04:40:40Z","receivedAt":"2010-05-29T04:40:40Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"This is needed by the following commits, because we are going\nto cherry pick many commits instead of just one.\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/revert.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin/revert.c b/builtin/revert.c\nindex 7976b5a..9737ad5 100644\n--- a/builtin/revert.c\n+++ b/builtin/revert.c\n@@ -534,7 +534,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)\n \t\t\targs[i++] = defmsg;\n \t\t}\n \t\targs[i] = NULL;\n-\t\treturn execv_git_cmd(args);\n+\t\treturn run_command_v_opt(args, RUN_GIT_CMD);\n \t}\n \tfree_message(&msg);\n \tfree(defmsg);\n-- \n1.7.1.346.g7c1d7.dirty\n"},{"id":"142522","messageId":"20100529044044.569.69037.chriscool@tuxfamily.org","threadId":"23937","inReplyTo":"20100529043738.569.85482.chriscool@tuxfamily.org","subject":"[RFC/PATCH 2/4] revert: refactor code into a do_pick_commit() function","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2010-05-29T04:40:41Z","receivedAt":"2010-05-29T04:40:41Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"This is needed because we are going to make it possible\nto cherry-pick many commits instead of just one in the following\ncommit. And we will be able to do that by just calling\ndo_pick_commit() one for each commit to cherry-pick.\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/revert.c |   52 +++++++++++++++++++++++++++++-----------------------\n 1 files changed, 29 insertions(+), 23 deletions(-)\n\ndiff --git a/builtin/revert.c b/builtin/revert.c\nindex 9737ad5..70372dc 100644\n--- a/builtin/revert.c\n+++ b/builtin/revert.c\n@@ -365,7 +365,7 @@ static void do_recursive_merge(struct commit *base, struct commit *next,\n \tfprintf(stderr, \"Finished one %s.\\n\", me);\n }\n \n-static int revert_or_cherry_pick(int argc, const char **argv)\n+static int do_pick_commit()\n {\n \tunsigned char head[20];\n \tstruct commit *base, *next, *parent;\n@@ -374,28 +374,6 @@ static int revert_or_cherry_pick(int argc, const char **argv)\n \tchar *defmsg = NULL;\n \tstruct strbuf msgbuf = STRBUF_INIT;\n \n-\tgit_config(git_default_config, NULL);\n-\tme = action == REVERT ? \"revert\" : \"cherry-pick\";\n-\tsetenv(GIT_REFLOG_ACTION, me, 0);\n-\tparse_args(argc, argv);\n-\n-\t/* this is copied from the shell script, but it's never triggered... */\n-\tif (action == REVERT && !no_replay)\n-\t\tdie(\"revert is incompatible with replay\");\n-\n-\tif (allow_ff) {\n-\t\tif (signoff)\n-\t\t\tdie(\"cherry-pick --ff cannot be used with --signoff\");\n-\t\tif (no_commit)\n-\t\t\tdie(\"cherry-pick --ff cannot be used with --no-commit\");\n-\t\tif (no_replay)\n-\t\t\tdie(\"cherry-pick --ff cannot be used with -x\");\n-\t\tif (edit)\n-\t\t\tdie(\"cherry-pick --ff cannot be used with --edit\");\n-\t}\n-\n-\tif (read_cache() < 0)\n-\t\tdie(\"git %s: failed to read the index\", me);\n \tif (no_commit) {\n \t\t/*\n \t\t * We do not intend to commit immediately.  We just want to\n@@ -542,6 +520,34 @@ static int revert_or_cherry_pick(int argc, const char **argv)\n \treturn 0;\n }\n \n+static int revert_or_cherry_pick(int argc, const char **argv)\n+{\n+\tgit_config(git_default_config, NULL);\n+\tme = action == REVERT ? \"revert\" : \"cherry-pick\";\n+\tsetenv(GIT_REFLOG_ACTION, me, 0);\n+\tparse_args(argc, argv);\n+\n+\t/* this is copied from the shell script, but it's never triggered... */\n+\tif (action == REVERT && !no_replay)\n+\t\tdie(\"revert is incompatible with replay\");\n+\n+\tif (allow_ff) {\n+\t\tif (signoff)\n+\t\t\tdie(\"cherry-pick --ff cannot be used with --signoff\");\n+\t\tif (no_commit)\n+\t\t\tdie(\"cherry-pick --ff cannot be used with --no-commit\");\n+\t\tif (no_replay)\n+\t\t\tdie(\"cherry-pick --ff cannot be used with -x\");\n+\t\tif (edit)\n+\t\t\tdie(\"cherry-pick --ff cannot be used with --edit\");\n+\t}\n+\n+\tif (read_cache() < 0)\n+\t\tdie(\"git %s: failed to read the index\", me);\n+\n+\treturn do_pick_commit();\n+}\n+\n int cmd_revert(int argc, const char **argv, const char *prefix)\n {\n \tif (isatty(0))\n-- \n1.7.1.346.g7c1d7.dirty\n"},{"id":"142519","messageId":"20100529044044.569.7874.chriscool@tuxfamily.org","threadId":"23937","inReplyTo":"20100529043738.569.85482.chriscool@tuxfamily.org","subject":"[RFC/PATCH 3/4] revert: allow cherry-picking a range of commits","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2010-05-29T04:40:42Z","receivedAt":"2010-05-29T04:40:42Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"This makes it possible to pass a range of commits like A..B\nto \"git cherry-pick\" and to \"git revert\" to process many\ncommits instead of just one.\n\nBut there is currently no way to continue cherry-picking or\nreverting if there is a problem with one commit. It's also\nnot possible to abort the whole process. Some future work\nshould provide the --continue and --abort options to do\njust that.\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/revert.c |   43 +++++++++++++++++++++++++++++++++++++------\n 1 files changed, 37 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin/revert.c b/builtin/revert.c\nindex 70372dc..c281a80 100644\n--- a/builtin/revert.c\n+++ b/builtin/revert.c\n@@ -53,7 +53,6 @@ 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-\tunsigned char sha1[20];\n \tint noop;\n \tstruct option options[] = {\n \t\tOPT_BOOLEAN('n', \"no-commit\", &no_commit, \"don't automatically commit\"),\n@@ -82,11 +81,6 @@ static void parse_args(int argc, const char **argv)\n \t\tusage_with_options(usage_str, options);\n \n \tcommit_name = argv[0];\n-\tif (get_sha1(commit_name, sha1))\n-\t\tdie (\"Cannot find '%s'\", commit_name);\n-\tcommit = lookup_commit_reference(sha1);\n-\tif (!commit)\n-\t\texit(1);\n }\n \n struct commit_message {\n@@ -522,6 +516,9 @@ static int do_pick_commit()\n \n static int revert_or_cherry_pick(int argc, const char **argv)\n {\n+\tconst char *dotdot;\n+\tunsigned char sha1[20];\n+\n \tgit_config(git_default_config, NULL);\n \tme = action == REVERT ? \"revert\" : \"cherry-pick\";\n \tsetenv(GIT_REFLOG_ACTION, me, 0);\n@@ -545,6 +542,40 @@ static int revert_or_cherry_pick(int argc, const char **argv)\n \tif (read_cache() < 0)\n \t\tdie(\"git %s: failed to read the index\", me);\n \n+\tdotdot = strstr(commit_name, \"..\");\n+\tif (dotdot) {\n+\t\tstruct rev_info revs;\n+\t\tconst char *argv[4];\n+\t\tint argc = 0;\n+\n+\t\targv[argc++] = NULL;\n+\t\tif (action != REVERT)\n+\t\t\targv[argc++] = \"--reverse\";\n+\t\targv[argc++] = commit_name;\n+\t\targv[argc++] = NULL;\n+\n+\t\tinit_revisions(&revs, NULL);\n+\t\tsetup_revisions(argc - 1, argv, &revs, NULL);\n+\t\tif (prepare_revision_walk(&revs))\n+\t\t\tdie(\"revision walk setup failed\");\n+\n+\t\tif (!revs.commits)\n+\t\t\tdie(\"empty range passed\");\n+\n+\t\twhile ( (commit = get_revision(&revs)) ) {\n+\t\t\tint res = do_pick_commit();\n+\t\t\tif (res)\n+\t\t\t\treturn res;\n+\t\t}\n+\t\treturn 0;\n+\t}\n+\n+\tif (get_sha1(commit_name, sha1))\n+\t\tdie (\"Cannot find '%s'\", commit_name);\n+\tcommit = lookup_commit_reference(sha1);\n+\tif (!commit)\n+\t\texit(1);\n+\n \treturn do_pick_commit();\n }\n \n-- \n1.7.1.346.g7c1d7.dirty\n"},{"id":"142520","messageId":"20100529044044.569.79624.chriscool@tuxfamily.org","threadId":"23937","inReplyTo":"20100529043738.569.85482.chriscool@tuxfamily.org","subject":"[RFC/PATCH 4/4] revert: add tests to check cherry-picking a range of commits","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2010-05-29T04:40:43Z","receivedAt":"2010-05-29T04:40:43Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n t/t3508-cherry-pick-range.sh |   65 ++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 65 insertions(+), 0 deletions(-)\n create mode 100755 t/t3508-cherry-pick-range.sh\n\ndiff --git a/t/t3508-cherry-pick-range.sh b/t/t3508-cherry-pick-range.sh\nnew file mode 100755\nindex 0000000..d83b74b\n--- /dev/null\n+++ b/t/t3508-cherry-pick-range.sh\n@@ -0,0 +1,65 @@\n+#!/bin/sh\n+\n+test_description='test cherry-picking a range of commits'\n+\n+. ./test-lib.sh\n+\n+test_expect_success setup '\n+\techo first > file1 &&\n+\tgit add file1 &&\n+\ttest_tick &&\n+\tgit commit -m \"first\" &&\n+\tgit tag first &&\n+\n+\tgit checkout -b other &&\n+\tfor val in second third fourth\n+\tdo\n+\t\techo $val >> file1 &&\n+\t\tgit add file1 &&\n+\t\ttest_tick &&\n+\t\tgit commit -m \"$val\" &&\n+\t\tgit tag $val\n+\tdone\n+'\n+\n+test_expect_success 'cherry-pick first..fourth works' '\n+\tgit checkout master &&\n+\tgit reset --hard first &&\n+\ttest_tick &&\n+\tgit cherry-pick first..fourth &&\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_expect_success 'cherry-pick --ff first..fourth works' '\n+\tgit checkout master &&\n+\tgit reset --hard first &&\n+\ttest_tick &&\n+\tgit cherry-pick --ff first..fourth &&\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_expect_success 'cherry-pick -n first..fourth works' '\n+\tgit checkout master &&\n+\tgit reset --hard first &&\n+\ttest_tick &&\n+\tgit cherry-pick -n first..fourth &&\n+\tgit diff --quiet other &&\n+\tgit diff --cached --quiet other &&\n+\tgit diff --quiet HEAD first\n+'\n+\n+test_expect_success 'revert first..fourth works' '\n+\tgit checkout master &&\n+\tgit reset --hard fourth &&\n+\ttest_tick &&\n+\tgit revert first..fourth &&\n+\tgit diff --quiet first &&\n+\tgit diff --cached --quiet first &&\n+\tgit diff --quiet HEAD first\n+'\n+\n+test_done\n-- \n1.7.1.346.g7c1d7.dirty\n"},{"id":"142533","messageId":"AANLkTilgOu1siF2ORrF7vspmL8Vsvsvz20dKNkSBKb3F@mail.gmail.com","threadId":"23937","inReplyTo":"20100529043738.569.85482.chriscool@tuxfamily.org","subject":"Re: [RFC/PATCH 0/4] implement \"git cherry-pick A..B\"","fromName":"Sverre Rabbelier","fromEmail":"srabbelier@gmail.com","sentAt":"2010-05-29T13:12:23Z","receivedAt":"2010-05-29T13:12:23Z","isPatch":true,"sender":{"key":"srabbelier@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3098?v=4"},"body":"Heya,\n\nOn Sat, May 29, 2010 at 06:40, Christian Couder <chriscool@tuxfamily.org> wrote:\n> This an RFC patch series to implement \"git cherry-pick A..B\" and\n> \"git revert A..B\".\n\nAwesome! Please keep working on this, I would love to see this implemented :).\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"142536","messageId":"7vmxvi4tkq.fsf@alter.siamese.dyndns.org","threadId":"23937","inReplyTo":"20100529044044.569.7874.chriscool@tuxfamily.org","subject":"Re: [RFC/PATCH 3/4] revert: allow cherry-picking a range of commits","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-05-29T15:27:01Z","receivedAt":"2010-05-29T15:27:01Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Christian Couder <chriscool@tuxfamily.org> writes:\n\n> This makes it possible to pass a range of commits like A..B\n> to \"git cherry-pick\" and to \"git revert\" to process many\n> commits instead of just one.\n\n> @@ -545,6 +542,40 @@ static int revert_or_cherry_pick(int argc, const char **argv)\n>  \tif (read_cache() < 0)\n>  \t\tdie(\"git %s: failed to read the index\", me);\n>  \n> +\tdotdot = strstr(commit_name, \"..\");\n> +\tif (dotdot) {\n> +\t\tstruct rev_info revs;\n> +\t\tconst char *argv[4];\n> +\t\tint argc = 0;\n> +\n> +\t\targv[argc++] = NULL;\n> +\t\tif (action != REVERT)\n> +\t\t\targv[argc++] = \"--reverse\";\n> +\t\targv[argc++] = commit_name;\n> +\t\targv[argc++] = NULL;\n> +\n> +\t\tinit_revisions(&revs, NULL);\n\nThe goal of the series is a worthy one, but I would imagine people would\nwant to run these while on \"maint\":\n\n    git cherry-pick master~2..master\n    git cherry-pick master^ master\n\nor even\n\n    git cherry-pick -2 master\n\nHow about enumerating the commits with an equivalent of\n\n    git rev-list --no-walk \"$@\"\n\nas an alternative implementation?\n\nThe current behaviour would fall out just as a natural special case\nbecause\n\n    git rev-list --no-walk $commit == $commit\n\nHmm?\n"},{"id":"142539","messageId":"alpine.DEB.1.00.1005291743300.1638@bonsai2","threadId":"23937","inReplyTo":"20100529044044.569.7874.chriscool@tuxfamily.org","subject":"Re: [RFC/PATCH 3/4] revert: allow cherry-picking a range of commits","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2010-05-29T15:47:10Z","receivedAt":"2010-05-29T15:47:10Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sat, 29 May 2010, Christian Couder wrote:\n\n> diff --git a/builtin/revert.c b/builtin/revert.c\n> index 70372dc..c281a80 100644\n> --- a/builtin/revert.c\n> +++ b/builtin/revert.c\n> @@ -545,6 +542,40 @@ static int revert_or_cherry_pick(int argc, const char **argv)\n>  \tif (read_cache() < 0)\n>  \t\tdie(\"git %s: failed to read the index\", me);\n>  \n> +\tdotdot = strstr(commit_name, \"..\");\n> +\tif (dotdot) {\n> +\t\tstruct rev_info revs;\n> +\t\tconst char *argv[4];\n> +\t\tint argc = 0;\n> +\n> +\t\targv[argc++] = NULL;\n> +\t\tif (action != REVERT)\n> +\t\t\targv[argc++] = \"--reverse\";\n> +\t\targv[argc++] = commit_name;\n> +\t\targv[argc++] = NULL;\n\nMaybe \"--no-merges\"?\n\n> +\t\tinit_revisions(&revs, NULL);\n> +\t\tsetup_revisions(argc - 1, argv, &revs, NULL);\n> +\t\tif (prepare_revision_walk(&revs))\n> +\t\t\tdie(\"revision walk setup failed\");\n> +\n> +\t\tif (!revs.commits)\n> +\t\t\tdie(\"empty range passed\");\n> +\n> +\t\twhile ( (commit = get_revision(&revs)) ) {\n\nThe style more in linet with the rest of the source code would be:\n\n\t\twhile ((commit = get_revision(&revs))) {\n\nThe rest of the patch series looks very, very good to me. I totally agree \nthat we do not have to implement the --abort and --continue for now, as \nwell as the HEAD-detaching business we're used to from rebase and am.\n\nThanks,\nDscho\n"},{"id":"142553","messageId":"201005300841.15606.chriscool@tuxfamily.org","threadId":"23937","inReplyTo":"7vmxvi4tkq.fsf@alter.siamese.dyndns.org","subject":"Re: [RFC/PATCH 3/4] revert: allow cherry-picking a range of commits","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2010-05-30T06:41:15Z","receivedAt":"2010-05-30T06:41:15Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Saturday 29 May 2010 17:27:01 Junio C Hamano wrote:\n> Christian Couder <chriscool@tuxfamily.org> writes:\n> > This makes it possible to pass a range of commits like A..B\n> > to \"git cherry-pick\" and to \"git revert\" to process many\n> > commits instead of just one.\n> >\n> > @@ -545,6 +542,40 @@ static int revert_or_cherry_pick(int argc, const\n> > char **argv) if (read_cache() < 0)\n> >  \t\tdie(\"git %s: failed to read the index\", me);\n> >\n> > +\tdotdot = strstr(commit_name, \"..\");\n> > +\tif (dotdot) {\n> > +\t\tstruct rev_info revs;\n> > +\t\tconst char *argv[4];\n> > +\t\tint argc = 0;\n> > +\n> > +\t\targv[argc++] = NULL;\n> > +\t\tif (action != REVERT)\n> > +\t\t\targv[argc++] = \"--reverse\";\n> > +\t\targv[argc++] = commit_name;\n> > +\t\targv[argc++] = NULL;\n> > +\n> > +\t\tinit_revisions(&revs, NULL);\n> \n> The goal of the series is a worthy one, but I would imagine people would\n> want to run these while on \"maint\":\n> \n>     git cherry-pick master~2..master\n>     git cherry-pick master^ master\n> \n> or even\n> \n>     git cherry-pick -2 master\n> \n> How about enumerating the commits with an equivalent of\n> \n>     git rev-list --no-walk \"$@\"\n> \n> as an alternative implementation?\n\nI agree that it would be nice, but I am not sure it would allow using \"-2 \nmaster\" as arguments because \"--no-walk\" seems to take over \"-2\": \n\n$ git rev-list --no-walk -2 master\n81fa024cd8e336ba257f13fe7724b95baacfa3ad\n$\n\n> The current behaviour would fall out just as a natural special case\n> because\n> \n>     git rev-list --no-walk $commit == $commit\n> \n> Hmm?\n\nYes, I will provide an updated patch series using the equivalent of '--no-walk \n\"$@\"' but arguments like \"-2 master\" will not work.\n\nThanks,\nChristian.\n\n\n \n"},{"id":"142554","messageId":"201005300845.52141.chriscool@tuxfamily.org","threadId":"23937","inReplyTo":"alpine.DEB.1.00.1005291743300.1638@bonsai2","subject":"Re: [RFC/PATCH 3/4] revert: allow cherry-picking a range of commits","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2010-05-30T06:45:52Z","receivedAt":"2010-05-30T06:45:52Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Saturday 29 May 2010 17:47:10 Johannes Schindelin wrote:\nHi Dscho,\n\n> Hi,\n> \n> On Sat, 29 May 2010, Christian Couder wrote:\n> > diff --git a/builtin/revert.c b/builtin/revert.c\n> > index 70372dc..c281a80 100644\n> > --- a/builtin/revert.c\n> > +++ b/builtin/revert.c\n> > @@ -545,6 +542,40 @@ static int revert_or_cherry_pick(int argc, const\n> > char **argv) if (read_cache() < 0)\n> >  \t\tdie(\"git %s: failed to read the index\", me);\n> >\n> > +\tdotdot = strstr(commit_name, \"..\");\n> > +\tif (dotdot) {\n> > +\t\tstruct rev_info revs;\n> > +\t\tconst char *argv[4];\n> > +\t\tint argc = 0;\n> > +\n> > +\t\targv[argc++] = NULL;\n> > +\t\tif (action != REVERT)\n> > +\t\t\targv[argc++] = \"--reverse\";\n> > +\t\targv[argc++] = commit_name;\n> > +\t\targv[argc++] = NULL;\n> \n> Maybe \"--no-merges\"?\n\nI will have a look at it. Thanks!\n \n> > +\t\tinit_revisions(&revs, NULL);\n> > +\t\tsetup_revisions(argc - 1, argv, &revs, NULL);\n> > +\t\tif (prepare_revision_walk(&revs))\n> > +\t\t\tdie(\"revision walk setup failed\");\n> > +\n> > +\t\tif (!revs.commits)\n> > +\t\t\tdie(\"empty range passed\");\n> > +\n> > +\t\twhile ( (commit = get_revision(&revs)) ) {\n> \n> The style more in linet with the rest of the source code would be:\n> \n> \t\twhile ((commit = get_revision(&revs))) {\n\nOk.\n\n> The rest of the patch series looks very, very good to me. I totally agree\n> that we do not have to implement the --abort and --continue for now, as\n> well as the HEAD-detaching business we're used to from rebase and am.\n\nThanks for the kind words,\nChristian.\n"},{"id":"142556","messageId":"201005300941.16452.chriscool@tuxfamily.org","threadId":"23937","inReplyTo":"AANLkTilgOu1siF2ORrF7vspmL8Vsvsvz20dKNkSBKb3F@mail.gmail.com","subject":"Re: [RFC/PATCH 0/4] implement \"git cherry-pick A..B\"","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2010-05-30T07:41:16Z","receivedAt":"2010-05-30T07:41:16Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Saturday 29 May 2010 15:12:23 Sverre Rabbelier wrote:\n> Heya,\n> \n> On Sat, May 29, 2010 at 06:40, Christian Couder <chriscool@tuxfamily.org> \nwrote:\n> > This an RFC patch series to implement \"git cherry-pick A..B\" and\n> > \"git revert A..B\".\n> \n> Awesome! Please keep working on this, I would love to see this implemented\n>  :).\n\nYeah, I will continue working on this.\n\nThanks for the kind words,\nChristian.\n"},{"id":"142568","messageId":"AANLkTik6SBEkOICHdMYprzGitfS2hezDXKQ8Q5R8cAYs@mail.gmail.com","threadId":"23937","inReplyTo":"20100529044044.569.69037.chriscool@tuxfamily.org","subject":"Re: [RFC/PATCH 2/4] revert: refactor code into a do_pick_commit() function","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2010-05-30T11:19:39Z","receivedAt":"2010-05-30T11:19:39Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Hi Christian,\n\nExcellent feature to work on- I've wanted to cherry pick a range several times.\n\nChristian Couder wrote:\n> -static int revert_or_cherry_pick(int argc, const char **argv)\n> +static int do_pick_commit()\n>  {\n>        unsigned char head[20];\n>        struct commit *base, *next, *parent;\n\nIs there a better way to do this instead of allocating memory for each\ncommit? When you cherry pick a lot of commits, it might make sense to\nuse a shared memory pool.\n\n> +       /* this is copied from the shell script, but it's never triggered... */\n> +       if (action == REVERT && !no_replay)\n> +               die(\"revert is incompatible with replay\");\n\nIf it's here for historical reasons, why don't you remove it now?\n\n-- Ram\n"},{"id":"142582","messageId":"20100530200708.GA32728@progeny.tock","threadId":"23937","inReplyTo":"AANLkTik6SBEkOICHdMYprzGitfS2hezDXKQ8Q5R8cAYs@mail.gmail.com","subject":"Re: [RFC/PATCH 2/4] revert: refactor code into a do_pick_commit() function","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-05-30T20:07:08Z","receivedAt":"2010-05-30T20:07:08Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Ramkumar Ramachandra wrote:\n> Christian Couder wrote:\n\n>> -static int revert_or_cherry_pick(int argc, const char **argv)\n>> +static int do_pick_commit()\n>>  {\n>>        unsigned char head[20];\n>>        struct commit *base, *next, *parent;\n>\n> Is there a better way to do this instead of allocating memory for each\n> commit? When you cherry pick a lot of commits, it might make sense to\n> use a shared memory pool.\n\nIn fact they do belong to a pool, as far as I can tell.\n\n  lookup_commit_reference ->\n   lookup_commit_reference_gently ->\n    parse_object ->\n     parse_object_buffer ->\n      lookup_commit ->\n       lookup_object (or create_object, alloc_commit_node)\n\nalloc_commit_node is defined in alloc.c to draw from a growing array\nof fixed-size, never-freed commit objects.\n\nHope that helps.\nJonathan\n"},{"id":"142583","messageId":"201005302229.46979.chriscool@tuxfamily.org","threadId":"23937","inReplyTo":"AANLkTik6SBEkOICHdMYprzGitfS2hezDXKQ8Q5R8cAYs@mail.gmail.com","subject":"Re: [RFC/PATCH 2/4] revert: refactor code into a do_pick_commit() function","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2010-05-30T20:29:46Z","receivedAt":"2010-05-30T20:29:46Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Hi Ram,\n\nOn Sunday 30 May 2010 13:19:39 Ramkumar Ramachandra wrote:\n> Hi Christian,\n> \n> Excellent feature to work on- I've wanted to cherry pick a range several\n>  times.\n\nThanks!\n\n> Christian Couder wrote:\n> > -static int revert_or_cherry_pick(int argc, const char **argv)\n> > +static int do_pick_commit()\n> >  {\n> >        unsigned char head[20];\n> >        struct commit *base, *next, *parent;\n> \n> Is there a better way to do this instead of allocating memory for each\n> commit? When you cherry pick a lot of commits, it might make sense to\n> use a shared memory pool.\n\nI think that most of the time I will cherry pick less than 20 commits so I \nthink the memory usage is not so important. And in any case it could be \nimproved later if there is a real need.\n\n> > +       /* this is copied from the shell script, but it's never\n> > triggered... */ +       if (action == REVERT && !no_replay)\n> > +               die(\"revert is incompatible with replay\");\n> \n> If it's here for historical reasons, why don't you remove it now?\n\nRight, I will have a look at removing that.\n\nThanks,\nChristian.\n"},{"id":"142638","messageId":"201006010512.49804.chriscool@tuxfamily.org","threadId":"23937","inReplyTo":"201005300845.52141.chriscool@tuxfamily.org","subject":"Re: [RFC/PATCH 3/4] revert: allow cherry-picking a range of commits","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2010-06-01T03:12:49Z","receivedAt":"2010-06-01T03:12:49Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Sunday 30 May 2010 08:45:52 Christian Couder wrote:\n> On Saturday 29 May 2010 17:47:10 Johannes Schindelin wrote:\nHi Dscho,\n\n> Hi Dscho,\n> \n> > Hi,\n> >\n> > On Sat, 29 May 2010, Christian Couder wrote:\n> > > diff --git a/builtin/revert.c b/builtin/revert.c\n> > > index 70372dc..c281a80 100644\n> > > --- a/builtin/revert.c\n> > > +++ b/builtin/revert.c\n> > > @@ -545,6 +542,40 @@ static int revert_or_cherry_pick(int argc, const\n> > > char **argv) if (read_cache() < 0)\n> > >  \t\tdie(\"git %s: failed to read the index\", me);\n> > >\n> > > +\tdotdot = strstr(commit_name, \"..\");\n> > > +\tif (dotdot) {\n> > > +\t\tstruct rev_info revs;\n> > > +\t\tconst char *argv[4];\n> > > +\t\tint argc = 0;\n> > > +\n> > > +\t\targv[argc++] = NULL;\n> > > +\t\tif (action != REVERT)\n> > > +\t\t\targv[argc++] = \"--reverse\";\n> > > +\t\targv[argc++] = commit_name;\n> > > +\t\targv[argc++] = NULL;\n> >\n> > Maybe \"--no-merges\"?\n> \n> I will have a look at it. Thanks!\n\nI decided against using it as it would be incompatible with the -m option to \nrevert or cherry-pick a merge.\n\nThanks,\nChristian.\n"}]}