{"thread":{"id":"23958","subject":"[PATCH 2/8] revert: use run_command_v_opt() instead of execv_git_cmd()","startedAt":"2010-05-31T19:42:31Z","lastAt":"2010-06-14T03:33:10Z","messageCount":30,"participants":["Christian Couder","Jonathan Nieder","Jeff King","Sverre Rabbelier","Ramkumar Ramachandra","Antriksh Pany","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":8},"messages":[{"id":"142630","messageId":"20100531193359.28729.55562.chriscool@tuxfamily.org","threadId":"23958","inReplyTo":null,"subject":"[PATCH 0/8] implement cherry-picking many commits","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2010-05-31T19:42:31Z","receivedAt":"2010-05-31T19:42:31Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"This a patch series to implement cherry-picking and reverting\nmany commits instead of just one.\n\nThere is still no way to continue or abort the process when\ncherry-picking or reverting fails, but this can be implemented\nlater.\n\nChanges since the previous RFC series are the following:\n\n- now use the equivalent of 'git rev-list --no-walk \"$@\"' to\nenumerate the commits (suggested by Junio)\n- added a patch to cleanup the code related to the -x option\n(suggested by Ram)\n- added a commit to change help_msg() and its callers\n- added 2 documentation patches \n\nChristian Couder (8):\n  revert: cleanup code for -x option\n  revert: use run_command_v_opt() instead of execv_git_cmd()\n  revert: refactor code into a do_pick_commit() function\n  revert: change help_msg() to take no argument\n  revert: allow cherry-picking more than one commit\n  revert: add tests to check cherry-picking many commits\n  Documentation/cherry-pick: describe passing more than one commit\n  Documentation/revert: describe passing more than one commit\n\n Documentation/git-cherry-pick.txt   |   64 ++++++++++++++++-----\n Documentation/git-revert.txt        |   52 +++++++++++------\n builtin/revert.c                    |  109 ++++++++++++++++++++++-------------\n t/t3508-cherry-pick-many-commits.sh |   95 ++++++++++++++++++++++++++++++\n 4 files changed, 249 insertions(+), 71 deletions(-)\n create mode 100755 t/t3508-cherry-pick-many-commits.sh\n"},{"id":"142631","messageId":"20100531194240.28729.10576.chriscool@tuxfamily.org","threadId":"23958","inReplyTo":"20100531193359.28729.55562.chriscool@tuxfamily.org","subject":"[PATCH 1/8] revert: cleanup code for -x option","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2010-05-31T19:42:32Z","receivedAt":"2010-05-31T19:42:32Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"There was some dead code and option -x appeared in the short\nhelp message of git revert (when running \"git revert -h\")\nwhich was wrong.\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/revert.c |    8 +-------\n 1 files changed, 1 insertions(+), 7 deletions(-)\n\ndiff --git a/builtin/revert.c b/builtin/revert.c\nindex 7976b5a..5df0d69 100644\n--- a/builtin/revert.c\n+++ b/builtin/revert.c\n@@ -58,7 +58,6 @@ static void parse_args(int argc, const char **argv)\n \tstruct option options[] = {\n \t\tOPT_BOOLEAN('n', \"no-commit\", &no_commit, \"don't automatically commit\"),\n \t\tOPT_BOOLEAN('e', \"edit\", &edit, \"edit the commit message\"),\n-\t\tOPT_BOOLEAN('x', NULL, &no_replay, \"append commit name when cherry-picking\"),\n \t\tOPT_BOOLEAN('r', NULL, &noop, \"no-op (backward compatibility)\"),\n \t\tOPT_BOOLEAN('s', \"signoff\", &signoff, \"add Signed-off-by:\"),\n \t\tOPT_INTEGER('m', \"mainline\", &mainline, \"parent number\"),\n@@ -71,6 +70,7 @@ static void parse_args(int argc, const char **argv)\n \n \tif (action == CHERRY_PICK) {\n \t\tstruct option cp_extra[] = {\n+\t\t\tOPT_BOOLEAN('x', NULL, &no_replay, \"append commit name\"),\n \t\t\tOPT_BOOLEAN(0, \"ff\", &allow_ff, \"allow fast-forward\"),\n \t\t\tOPT_END(),\n \t\t};\n@@ -379,10 +379,6 @@ static int revert_or_cherry_pick(int argc, const char **argv)\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@@ -546,14 +542,12 @@ int cmd_revert(int argc, const char **argv, const char *prefix)\n {\n \tif (isatty(0))\n \t\tedit = 1;\n-\tno_replay = 1;\n \taction = REVERT;\n \treturn revert_or_cherry_pick(argc, argv);\n }\n \n int cmd_cherry_pick(int argc, const char **argv, const char *prefix)\n {\n-\tno_replay = 0;\n \taction = CHERRY_PICK;\n \treturn revert_or_cherry_pick(argc, argv);\n }\n-- \n1.7.1.361.g42de.dirty\n"},{"id":"142629","messageId":"20100531194240.28729.9964.chriscool@tuxfamily.org","threadId":"23958","inReplyTo":"20100531193359.28729.55562.chriscool@tuxfamily.org","subject":"[PATCH 2/8] revert: use run_command_v_opt() instead of execv_git_cmd()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2010-05-31T19:42:33Z","receivedAt":"2010-05-31T19:42:33Z","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 5df0d69..9085894 100644\n--- a/builtin/revert.c\n+++ b/builtin/revert.c\n@@ -530,7 +530,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.361.g42de.dirty\n"},{"id":"142632","messageId":"20100531194240.28729.42538.chriscool@tuxfamily.org","threadId":"23958","inReplyTo":"20100531193359.28729.55562.chriscool@tuxfamily.org","subject":"[PATCH 3/8] revert: refactor code into a do_pick_commit() function","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2010-05-31T19:42:34Z","receivedAt":"2010-05-31T19:42:34Z","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\ncommits. And we will be able to do that by just calling\ndo_pick_commit() once for each commit to cherry-pick.\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/revert.c |   44 +++++++++++++++++++++++++-------------------\n 1 files changed, 25 insertions(+), 19 deletions(-)\n\ndiff --git a/builtin/revert.c b/builtin/revert.c\nindex 9085894..070e02e 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,24 +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-\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@@ -538,6 +520,30 @@ 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+\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.361.g42de.dirty\n"},{"id":"142633","messageId":"20100531194240.28729.49459.chriscool@tuxfamily.org","threadId":"23958","inReplyTo":"20100531193359.28729.55562.chriscool@tuxfamily.org","subject":"[PATCH 4/8] revert: change help_msg() to take no argument","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2010-05-31T19:42:35Z","receivedAt":"2010-05-31T19:42:35Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"This is needed because the following commits will make it\npossible to cherry-pick many commits instead of just one.\n\nSo it will be possible to pass for example ranges of commits\nto \"git cherry-pick\" and this means that it will not be\npossible to use the arguments passed to \"git cherry-pick\" in\nthe help message.\n\nThe help message will have to use the sha1 of the currently\nprocessed commit.\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/revert.c |    8 ++++----\n 1 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/revert.c b/builtin/revert.c\nindex 070e02e..f0d78e5 100644\n--- a/builtin/revert.c\n+++ b/builtin/revert.c\n@@ -239,7 +239,7 @@ static void set_author_ident_env(const char *message)\n \t\t\tsha1_to_hex(commit->object.sha1));\n }\n \n-static char *help_msg(const char *name)\n+static char *help_msg(void)\n {\n \tstruct strbuf helpbuf = STRBUF_INIT;\n \tchar *msg = getenv(\"GIT_CHERRY_PICK_HELP\");\n@@ -255,7 +255,7 @@ static char *help_msg(const char *name)\n \t\tstrbuf_addf(&helpbuf, \" with: \\n\"\n \t\t\t\"\\n\"\n \t\t\t\"        git commit -c %s\\n\",\n-\t\t\tname);\n+\t\t\t    sha1_to_hex(commit->object.sha1));\n \t}\n \telse\n \t\tstrbuf_addch(&helpbuf, '.');\n@@ -357,7 +357,7 @@ static void do_recursive_merge(struct commit *base, struct commit *next,\n \t\t}\n \t\twrite_message(msgbuf, defmsg);\n \t\tfprintf(stderr, \"Automatic %s failed.%s\\n\",\n-\t\t\tme, help_msg(commit_name));\n+\t\t\tme, help_msg());\n \t\trerere(allow_rerere_auto);\n \t\texit(1);\n \t}\n@@ -484,7 +484,7 @@ static int do_pick_commit()\n \t\tfree_commit_list(remotes);\n \t\tif (res) {\n \t\t\tfprintf(stderr, \"Automatic %s with strategy %s failed.%s\\n\",\n-\t\t\t\tme, strategy, help_msg(commit_name));\n+\t\t\t\tme, strategy, help_msg());\n \t\t\trerere(allow_rerere_auto);\n \t\t\texit(1);\n \t\t}\n-- \n1.7.1.361.g42de.dirty\n"},{"id":"142634","messageId":"20100531194240.28729.9164.chriscool@tuxfamily.org","threadId":"23958","inReplyTo":"20100531193359.28729.55562.chriscool@tuxfamily.org","subject":"[PATCH 5/8] revert: allow cherry-picking more than one commit","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2010-05-31T19:42:36Z","receivedAt":"2010-05-31T19:42:36Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"This makes it possible to pass many commits or ranges of\ncommits to \"git cherry-pick\" and to \"git revert\" to process\nmany commits instead of just one.\n\nIn fact commits are now enumerated with an equivalent of\n\n\tgit rev-list --no-walk \"$@\"\n\nso all the following are now possible:\n\n\tgit cherry-pick master~2..master\n\tgit cherry-pick ^master~2 master\n\tgit cherry-pick master^ master\n\nThe following should be possible but does not work:\n\n\tgit cherry-pick -2 master\n\nbecause \"git rev-list --no-walk -2 master\" only outputs\none commit as \"--no-walk\" seems to take over \"-2\".\n\nAnd 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 |   49 +++++++++++++++++++++++++++++++++++++++----------\n 1 files changed, 39 insertions(+), 10 deletions(-)\n\ndiff --git a/builtin/revert.c b/builtin/revert.c\nindex f0d78e5..b90955f 100644\n--- a/builtin/revert.c\n+++ b/builtin/revert.c\n@@ -39,7 +39,8 @@ static const char * const cherry_pick_usage[] = {\n static int edit, no_replay, no_commit, mainline, signoff, allow_ff;\n static enum { REVERT, CHERRY_PICK } action;\n static struct commit *commit;\n-static const char *commit_name;\n+static int commit_argc;\n+static const char **commit_argv;\n static int allow_rerere_auto;\n \n static const char *me;\n@@ -53,7 +54,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@@ -78,15 +78,11 @@ static void parse_args(int argc, const char **argv)\n \t\t\tdie(\"program error\");\n \t}\n \n-\tif (parse_options(argc, argv, NULL, options, usage_str, 0) != 1)\n+\tcommit_argc = parse_options(argc, argv, NULL, options, usage_str, 0);\n+\tif (commit_argc < 1)\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+\tcommit_argv = argv;\n }\n \n struct commit_message {\n@@ -520,8 +516,33 @@ static int do_pick_commit()\n \treturn 0;\n }\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+\n+\tinit_revisions(revs, NULL);\n+\tsetup_revisions(argc - 1, argv, revs, NULL);\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+\n static int revert_or_cherry_pick(int argc, const char **argv)\n {\n+\tstruct rev_info revs;\n+\n \tgit_config(git_default_config, NULL);\n \tme = action == REVERT ? \"revert\" : \"cherry-pick\";\n \tsetenv(GIT_REFLOG_ACTION, me, 0);\n@@ -541,7 +562,15 @@ 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-\treturn do_pick_commit();\n+\tprepare_revs(&revs);\n+\n+\twhile ((commit = get_revision(&revs))) {\n+\t\tint res = do_pick_commit();\n+\t\tif (res)\n+\t\t\treturn res;\n+\t}\n+\n+\treturn 0;\n }\n \n int cmd_revert(int argc, const char **argv, const char *prefix)\n-- \n1.7.1.361.g42de.dirty\n"},{"id":"142635","messageId":"20100531194240.28729.28049.chriscool@tuxfamily.org","threadId":"23958","inReplyTo":"20100531193359.28729.55562.chriscool@tuxfamily.org","subject":"[PATCH 6/8] revert: add tests to check cherry-picking many commits","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2010-05-31T19:42:37Z","receivedAt":"2010-05-31T19:42:37Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Note that there is an expected failure when running:\n\n\tgit cherry-pick -3 fourth\n\nthat's because:\n\n\tgit rev-list --no-walk -3 fourth\n\nproduce only one commit and not 3 as \"--no-walk\" seems to\ntake over \"-3\".\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n t/t3508-cherry-pick-many-commits.sh |   95 +++++++++++++++++++++++++++++++++++\n 1 files changed, 95 insertions(+), 0 deletions(-)\n create mode 100755 t/t3508-cherry-pick-many-commits.sh\n\ndiff --git a/t/t3508-cherry-pick-many-commits.sh b/t/t3508-cherry-pick-many-commits.sh\nnew file mode 100755\nindex 0000000..3b87efe\n--- /dev/null\n+++ b/t/t3508-cherry-pick-many-commits.sh\n@@ -0,0 +1,95 @@\n+#!/bin/sh\n+\n+test_description='test cherry-picking many 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_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_expect_success 'revert fourth fourth~1 fourth~2 works' '\n+\tgit checkout master &&\n+\tgit reset --hard fourth &&\n+\ttest_tick &&\n+\tgit revert fourth fourth~1 fourth~2 &&\n+\tgit diff --quiet first &&\n+\tgit diff --cached --quiet first &&\n+\tgit diff --quiet HEAD first\n+'\n+\n+test_expect_failure 'cherry-pick -3 fourth works' '\n+\tgit checkout master &&\n+\tgit reset --hard first &&\n+\ttest_tick &&\n+\tgit cherry-pick -3 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_done\n-- \n1.7.1.361.g42de.dirty\n"},{"id":"142636","messageId":"20100531194240.28729.50475.chriscool@tuxfamily.org","threadId":"23958","inReplyTo":"20100531193359.28729.55562.chriscool@tuxfamily.org","subject":"[PATCH 7/8] Documentation/cherry-pick: describe passing more than one commit","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2010-05-31T19:42:38Z","receivedAt":"2010-05-31T19:42:38Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"And while at it, add an \"Examples\" section.\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n Documentation/git-cherry-pick.txt |   64 +++++++++++++++++++++++++++++--------\n 1 files changed, 50 insertions(+), 14 deletions(-)\n\ndiff --git a/Documentation/git-cherry-pick.txt b/Documentation/git-cherry-pick.txt\nindex d71607a..df2742a 100644\n--- a/Documentation/git-cherry-pick.txt\n+++ b/Documentation/git-cherry-pick.txt\n@@ -3,24 +3,29 @@ git-cherry-pick(1)\n \n NAME\n ----\n-git-cherry-pick - Apply the change introduced by an existing commit\n+git-cherry-pick - Apply the change 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] <commit>...\n \n DESCRIPTION\n -----------\n-Given one existing commit, apply the change the patch introduces, and record a\n-new commit that records it.  This requires your working tree to be clean (no\n-modifications from the HEAD commit).\n+\n+Given one or more existing commits, apply the changes that the related\n+patches introduce, and record some new commits that record them.  This\n+requires your working tree to be clean (no modifications from the HEAD\n+commit).\n \n OPTIONS\n -------\n-<commit>::\n-\tCommit to cherry-pick.\n+<commit>...::\n+\tCommits to cherry-pick.\n \tFor a more complete list of ways to spell commits, see the\n \t\"SPECIFYING REVISIONS\" section in linkgit:git-rev-parse[1].\n+\tSets of commits can also be given but no traversal is done\n+\tby default, see linkgit:git-rev-list[1] and its '--no-walk'\n+\toption.\n \n -e::\n --edit::\n@@ -55,13 +60,12 @@ OPTIONS\n \n -n::\n --no-commit::\n-\tUsually the command automatically creates a commit.\n-\tThis flag applies the change necessary to cherry-pick\n-\tthe named commit to your working tree and the index,\n-\tbut does not make the commit.  In addition, when this\n-\toption is used, your index does not have to match the\n-\tHEAD commit.  The cherry-pick is done against the\n-\tbeginning state of your index.\n+\tUsually the command automatically creates some commits.  This\n+\tflag applies the change necessary to cherry-pick the named\n+\tcommits to your working tree and the index, but does not make\n+\tthe commits.  In addition, when this option is used, your\n+\tindex does not have to match the HEAD commit.  The cherry-pick\n+\tis done against the beginning state of your index.\n +\n This is useful when cherry-picking more than one commits'\n effect to your index in a row.\n@@ -75,6 +79,38 @@ 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+Examples\n+--------\n+git cherry-pick master::\n+\n+\tApply the changes specified by the commit pointed to by master\n+\tand create a new commit with these changes.\n+\n+git cherry-pick master~3..master::\n+git cherry-pick ^master~3 master::\n+\n+\tApply the changes specified by the last 3 commits pointed to\n+\tby master and create 3 new commits with these changes.\n+\n+git cherry-pick master\\~3 master~2::\n+\n+\tApply the changes specified by the fourth and third last\n+\tcommits pointed to by master and create 2 new commits with\n+\tthese changes.\n+\n+git cherry-pick -n master~1 next::\n+\n+\tApply to the working tree and the index the changes specified\n+\tby the second last commit pointed to by master and by the last\n+\tcommit pointed to by next, but do not create any commit with\n+\tthese changes.\n+\n+git cherry-pick --ff ..next::\n+\n+\tIf possible fast forward to the existing commits already in\n+\tnext but not in HEAD, otherwise apply the changes specified by\n+\tthese commits and create new commits with these changes.\n+\n Author\n ------\n Written by Junio C Hamano <gitster@pobox.com>\n-- \n1.7.1.361.g42de.dirty\n"},{"id":"142637","messageId":"20100531194240.28729.15284.chriscool@tuxfamily.org","threadId":"23958","inReplyTo":"20100531193359.28729.55562.chriscool@tuxfamily.org","subject":"[PATCH 8/8] Documentation/revert: describe passing more than one commit","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2010-05-31T19:42:39Z","receivedAt":"2010-05-31T19:42:39Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"And while at it, add an \"Examples\" section.\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n Documentation/git-revert.txt |   52 ++++++++++++++++++++++++++++-------------\n 1 files changed, 35 insertions(+), 17 deletions(-)\n\ndiff --git a/Documentation/git-revert.txt b/Documentation/git-revert.txt\nindex c66bf80..5740f37 100644\n--- a/Documentation/git-revert.txt\n+++ b/Documentation/git-revert.txt\n@@ -3,20 +3,22 @@ git-revert(1)\n \n NAME\n ----\n-git-revert - Revert an existing commit\n+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] <commit>...\n \n DESCRIPTION\n -----------\n-Given one existing commit, revert the change the patch introduces, and record a\n-new commit that records it.  This requires your working tree to be clean (no\n-modifications from the HEAD commit).\n \n-Note: 'git revert' is used to record a new commit to reverse the\n-effect of an earlier commit (often a faulty one).  If you want to\n+Given one or more existing commits, revert the changes that the\n+related patches introduce, and record some new commits that record\n+them.  This requires your working tree to be clean (no modifications\n+from the HEAD commit).\n+\n+Note: 'git revert' is used to record some new commits to reverse the\n+effect of some earlier commits (often only a faulty one).  If you want to\n throw away all uncommitted changes in your working directory, you\n should see linkgit:git-reset[1], particularly the '--hard' option.  If\n you want to extract specific files as they were in another commit, you\n@@ -26,10 +28,13 @@ both will discard uncommitted changes in your working directory.\n \n OPTIONS\n -------\n-<commit>::\n-\tCommit to revert.\n+<commit>...::\n+\tCommits to revert.\n \tFor a more complete list of ways to spell commit names, see\n \t\"SPECIFYING REVISIONS\" section in linkgit:git-rev-parse[1].\n+\tSets of commits can also be given but no traversal is done by\n+\tdefault, see linkgit:git-rev-list[1] and its '--no-walk'\n+\toption.\n \n -e::\n --edit::\n@@ -59,14 +64,13 @@ more details.\n \n -n::\n --no-commit::\n-\tUsually the command automatically creates a commit with\n-\ta commit log message stating which commit was\n-\treverted.  This flag applies the change necessary\n-\tto revert the named commit to your working tree\n-\tand the index, but does not make the commit.  In addition,\n-\twhen this option is used, your index does not have to match\n-\tthe HEAD commit.  The revert is done against the\n-\tbeginning state of your index.\n+\tUsually the command automatically creates some commits with\n+\tcommit log messages stating which commits were reverted.  This\n+\tflag applies the changes necessary to revert the named commits\n+\tto your working tree and the index, but does not make the\n+\tcommits.  In addition, when this option is used, your index\n+\tdoes not have to match the HEAD commit.  The revert is done\n+\tagainst the beginning state of your index.\n +\n This is useful when reverting more than one commits'\n effect to your index in a row.\n@@ -75,6 +79,20 @@ effect to your index in a row.\n --signoff::\n \tAdd Signed-off-by line at the end of the commit message.\n \n+Examples\n+--------\n+git revert HEAD~3::\n+\n+\tRevert the changes specified by the fourth last commit in HEAD\n+\tand create a new commit with the reverted changes.\n+\n+git revert -n master\\~5..master~2::\n+\n+\tRevert the changes done by commits from the fiveth last commit\n+\tin master (included) to the third last commit in master\n+\t(included), but do not create any commit with the reverted\n+\tchanges. The revert only modifies the working tree and the\n+\tindex.\n \n Author\n ------\n-- \n1.7.1.361.g42de.dirty\n"},{"id":"142641","messageId":"20100601040115.GA22401@progeny.tock","threadId":"23958","inReplyTo":"20100531194240.28729.9964.chriscool@tuxfamily.org","subject":"Re: [PATCH 2/8] revert: use run_command_v_opt() instead of execv_git_cmd()","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-06-01T04:01:15Z","receivedAt":"2010-06-01T04:01:15Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Christian Couder wrote:\n\n> diff --git a/builtin/revert.c b/builtin/revert.c\n> index 5df0d69..9085894 100644\n> --- a/builtin/revert.c\n> +++ b/builtin/revert.c\n> @@ -530,7 +530,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\nDoesn’t this leak msg and defmsg?  Maybe it would make sense to free\nthe in-core copy of the commit message before the if (!no_commit)\nblock.\n\n\tint ret;\n\n\t...\n\tret = 0;\n\tfree_message(&msg);\n\tif (!no_commit)\n\t\tret = commit_for_cherry_pick(signoff, edit, defmsg);\n\tfree(defmsg);\n\treturn ret;\n\nJonathan\n"},{"id":"142644","messageId":"201006010633.08864.chriscool@tuxfamily.org","threadId":"23958","inReplyTo":"20100601040115.GA22401@progeny.tock","subject":"Re: [PATCH 2/8] revert: use run_command_v_opt() instead of execv_git_cmd()","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2010-06-01T04:33:08Z","receivedAt":"2010-06-01T04:33:08Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Tuesday 01 June 2010 06:01:15 Jonathan Nieder wrote:\n> Christian Couder wrote:\n> > diff --git a/builtin/revert.c b/builtin/revert.c\n> > index 5df0d69..9085894 100644\n> > --- a/builtin/revert.c\n> > +++ b/builtin/revert.c\n> > @@ -530,7 +530,7 @@ static int revert_or_cherry_pick(int argc, const char\n> > **argv) args[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> \n> Doesn’t this leak msg and defmsg?  Maybe it would make sense to free\n> the in-core copy of the commit message before the if (!no_commit)\n> block.\n\nYes, I will have a look at it.\n\nThanks,\nChristian.\n"},{"id":"142645","messageId":"20100601050815.GB22441@progeny.tock","threadId":"23958","inReplyTo":"20100531194240.28729.49459.chriscool@tuxfamily.org","subject":"Re: [PATCH 4/8] revert: change help_msg() to take no argument","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-06-01T05:08:15Z","receivedAt":"2010-06-01T05:08:15Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Christian Couder wrote:\n\n> +++ b/builtin/revert.c\n> @@ -239,7 +239,7 @@ static void set_author_ident_env(const char *message)\n>  \t\t\tsha1_to_hex(commit->object.sha1));\n>  }\n>  \n> -static char *help_msg(const char *name)\n> +static char *help_msg(void)\n>  {\n>  \tstruct strbuf helpbuf = STRBUF_INIT;\n>  \tchar *msg = getenv(\"GIT_CHERRY_PICK_HELP\");\n> @@ -255,7 +255,7 @@ static char *help_msg(const char *name)\n>  \t\tstrbuf_addf(&helpbuf, \" with: \\n\"\n>  \t\t\t\"\\n\"\n>  \t\t\t\"        git commit -c %s\\n\",\n> -\t\t\tname);\n> +\t\t\t    sha1_to_hex(commit->object.sha1));\n>  \t}\n>  \telse\n>  \t\tstrbuf_addch(&helpbuf, '.');\n\nproducing a message like\n\n  Automatic cherry-pick failed.\n    After resolving the conflicts,\n  mark the corrected paths with 'git add <paths>' or 'git rm <paths>'\n  and commit the result with: \n\n  \tgit commit -c 8a7cdf\n\nIs there any reason not to suggest ‘git commit’ without the -c?  This\nway, the template message includes a helpful Conflicts: string, too.\n\n---\n builtin/revert.c |    3 +--\n 1 files changed, 1 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/revert.c b/builtin/revert.c\nindex f0d78e5..bbafc41 100644\n--- a/builtin/revert.c\n+++ b/builtin/revert.c\n@@ -254,8 +254,7 @@ static char *help_msg(void)\n \tif (action == CHERRY_PICK) {\n \t\tstrbuf_addf(&helpbuf, \" with: \\n\"\n \t\t\t\"\\n\"\n-\t\t\t\"        git commit -c %s\\n\",\n-\t\t\t    sha1_to_hex(commit->object.sha1));\n+\t\t\t\"        git commit\\n\");\n \t}\n \telse\n \t\tstrbuf_addch(&helpbuf, '.');\n-- \n1.7.1\n"},{"id":"142647","messageId":"20100601054034.GA6638@sigill.intra.peff.net","threadId":"23958","inReplyTo":"20100601050815.GB22441@progeny.tock","subject":"Re: [PATCH 4/8] revert: change help_msg() to take no argument","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-06-01T05:40:35Z","receivedAt":"2010-06-01T05:40:35Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Jun 01, 2010 at 12:08:15AM -0500, Jonathan Nieder wrote:\n\n>   Automatic cherry-pick failed.\n>     After resolving the conflicts,\n>   mark the corrected paths with 'git add <paths>' or 'git rm <paths>'\n>   and commit the result with: \n> \n>   \tgit commit -c 8a7cdf\n> \n> Is there any reason not to suggest ‘git commit’ without the -c?  This\n> way, the template message includes a helpful Conflicts: string, too.\n\nYou cc'd me, which I guess means you git-blame'd the line in question.\nBut you really need to parent-blame about five steps back to find\nf52463a (cherry-pick: Suggest a better method to retain authorship,\n2007-03-04) from Dscho, which introduced the \"commit -c\" suggestion.\n\nSo the answer to your question is that \"-c\" will retain the proper\nauthorship of the cherry-picked commit. We could instead:\n\n  1. Say only \"git commit\" when author == committer.\n\n  2. When author and committer do not match, explicitly say \"git commit\n     --author=...\". This retains the \"conflicts\" information from the\n     template.\n\nThose are both easy.  Alternatively, we could actually make it stash the\noriginal authorship information somewhere (in addition to the commit\nmessage template) and then pull it out automatically. That's harder, but\nprobably what the user would want (and it behaves more like a rebase\nconflict).\n\n-Peff\n"},{"id":"142649","messageId":"20100601062745.GA27593@progeny.tock","threadId":"23958","inReplyTo":"20100601054034.GA6638@sigill.intra.peff.net","subject":"Re: [PATCH 4/8] revert: change help_msg() to take no argument","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-06-01T06:27:45Z","receivedAt":"2010-06-01T06:27:45Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Jeff King wrote:\n\n> You cc'd me, which I guess means you git-blame'd the line in question.\n> But you really need to parent-blame about five steps back\n\nWorse, I used ‘git log -- builtin-revert.c’ and stopped reading when\nit seemed you must know be current maintainer for that line.  Sorry\nabout that.\n\n> we could actually make it stash the\n> original authorship information somewhere (in addition to the commit\n> message template) and then pull it out automatically.\n\nI think that can wait for cherry-pick --continue.\n\nHere’s an ugly patch to use --author.  I call it ugly because the\nrelevant part of t3507-cherry-pick-conflict.sh output looks like\nthis:\n\n| Automatic cherry-pick failed.  After resolving the conflicts,\n| mark the corrected paths with 'git add <paths>' or 'git rm <paths>'\n| and commit the result with: \n| \n|         git commit --author='A U Thor <author@example.com>' \\\n|                     --date='1112912113 -0700'\n\nIn other words, the command is long and the date human-unfriendly.\n\nAnyway, given that cherry-pick --continue is just around the corner, I\nwithdraw my complaint about the ‘commit -c’ version.\n\nThanks for the pointer.\n\ndiff --git a/builtin/revert.c b/builtin/revert.c\nindex bbafc41..9b8e7d6 100644\n--- a/builtin/revert.c\n+++ b/builtin/revert.c\n@@ -252,9 +252,16 @@ static char *help_msg(void)\n \t\t\"and commit the result\");\n \n \tif (action == CHERRY_PICK) {\n+\t\tconst char *ident = git_author_info(IDENT_ERROR_ON_NO_NAME);\n+\t\tconst char *ident_end = ident ? strchr(ident, '>') : NULL;\n+\t\tif (!ident_end || ident_end[1] != ' ')\n+\t\t\tdie(\"git_author_info returned nonsense\");\n \t\tstrbuf_addf(&helpbuf, \" with: \\n\"\n \t\t\t\"\\n\"\n-\t\t\t\"        git commit\\n\");\n+\t\t\t\"        git commit --author='%.*s' \\\\\\n\"\n+\t\t\t\"                    --date='%s'\\n\",\n+\t\t\t(int) (ident_end + 1 - ident), ident,\n+\t\t\tident_end + 2);\n \t}\n \telse\n \t\tstrbuf_addch(&helpbuf, '.');\n"},{"id":"142655","messageId":"AANLkTilgx84KIrs-z0dX6ZaZWhBRGKwtJQO3hEUQPLRN@mail.gmail.com","threadId":"23958","inReplyTo":"20100531194240.28729.9164.chriscool@tuxfamily.org","subject":"Re: [PATCH 5/8] revert: allow cherry-picking more than one commit","fromName":"Sverre Rabbelier","fromEmail":"srabbelier@gmail.com","sentAt":"2010-06-01T07:38:29Z","receivedAt":"2010-06-01T07:38:29Z","isPatch":true,"sender":{"key":"srabbelier@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3098?v=4"},"body":"Heya,\n\nOn Mon, May 31, 2010 at 21:42, Christian Couder <chriscool@tuxfamily.org> wrote:\n> because \"git rev-list --no-walk -2 master\" only outputs\n> one commit as \"--no-walk\" seems to take over \"-2\".\n\nI don't understand this, what do you mean with \"take over\"? Is this a\nbug/missing feature in rev-list?\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"142659","messageId":"20100601083549.GA28377@progeny.tock","threadId":"23958","inReplyTo":"20100531194240.28729.9164.chriscool@tuxfamily.org","subject":"Re: [PATCH 5/8] revert: allow cherry-picking more than one commit","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-06-01T08:35:49Z","receivedAt":"2010-06-01T08:35:49Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Christian Couder wrote:\n\n> The following should be possible but does not work:\n> \n> \tgit cherry-pick -2 master\n> \n> because \"git rev-list --no-walk -2 master\" only outputs\n> one commit as \"--no-walk\" seems to take over \"-2\".\n\nAre the semantics of --no-walk documented anywhere?\n\nIn the spirit of v1.6.4-rc1~3 (Make 'git show' more useful,\n2009-07-13), we could make -n imply --do-walk.\n\nThis would change the meaning of git show -5 --all, so I am not too\nhappy with it.\n\n-- 8< --\nSubject: DWIM 'git show -5' to 'git show --do-walk -5'\n\nTo show the last two commits with one command, one might try\n\n 1) git show -s master~2..\n 2) git show -s ^master~2 master\n 3) git show -s master^ master\n 4) git show -s -2 master\n\nChoice (3) works because both commits are listed on the command line.\nChoices (1) and (2) have worked ever since v1.6.4-rc~3 (Make 'git\nshow' more useful, 2009-07-13) disabled --no-walk in this case because\nthere is no other useful meaning for them to have.  Unfortunately, (4)\ndoes not work: it outputs only one commit, because --no-walk stays on.\n\nSo disable --no-walk in this case so ‘git show’ and future ‘git\ncherry-pick’ can behave as expected.\n\nAs a side effect, this unfortunately changes the meaning of\n‘git log --oneline --decorate --no-walk -5 --all’: instead of listing\nfive refs, after this patch that command would list the five most\nrecent commits.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n revision.c |    4 ++++\n 1 files changed, 4 insertions(+), 0 deletions(-)\n\ndiff --git a/revision.c b/revision.c\nindex f4b8b38..7b881a8 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1063,18 +1063,22 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg\n \n \tif (!prefixcmp(arg, \"--max-count=\")) {\n \t\trevs->max_count = atoi(arg + 12);\n+\t\trevs->no_walk = 0;\n \t} else if (!prefixcmp(arg, \"--skip=\")) {\n \t\trevs->skip_count = atoi(arg + 7);\n \t} else if ((*arg == '-') && isdigit(arg[1])) {\n \t/* accept -<digit>, like traditional \"head\" */\n \t\trevs->max_count = atoi(arg + 1);\n+\t\trevs->no_walk = 0;\n \t} else if (!strcmp(arg, \"-n\")) {\n \t\tif (argc <= 1)\n \t\t\treturn error(\"-n requires an argument\");\n \t\trevs->max_count = atoi(argv[1]);\n+\t\trevs->no_walk = 0;\n \t\treturn 2;\n \t} else if (!prefixcmp(arg, \"-n\")) {\n \t\trevs->max_count = atoi(arg + 2);\n+\t\trevs->no_walk = 0;\n \t} else if (!prefixcmp(arg, \"--max-age=\")) {\n \t\trevs->max_age = atoi(arg + 10);\n \t} else if (!prefixcmp(arg, \"--since=\")) {\n-- \n1.7.1.246.g2fc1b.dirty\n"},{"id":"142662","messageId":"20100601090317.GB32320@progeny.tock","threadId":"23958","inReplyTo":"20100531194240.28729.9164.chriscool@tuxfamily.org","subject":"Re: [PATCH 5/8] revert: allow cherry-picking more than one commit","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-06-01T09:03:17Z","receivedAt":"2010-06-01T09:03:17Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Christian Couder wrote:\n\n> --- a/builtin/revert.c\n> +++ b/builtin/revert.c\n> @@ -520,8 +516,33 @@ static int do_pick_commit()\n>  \treturn 0;\n>  }\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> +\n> +\tinit_revisions(revs, NULL);\n> +\tsetup_revisions(argc - 1, argv, revs, NULL);\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\nTiny one-time leak.  Maybe avoiding it will make debugging tools\nhappier.\n\nThe rest of the patch of course looks good.  Thanks.\n\ndiff --git a/builtin/revert.c b/builtin/revert.c\nindex b90955f..a73f66b 100644\n--- a/builtin/revert.c\n+++ b/builtin/revert.c\n@@ -532,6 +532,7 @@ static void prepare_revs(struct rev_info *revs)\n \n \tinit_revisions(revs, NULL);\n \tsetup_revisions(argc - 1, argv, revs, NULL);\n+\tfree(argv);\n \tif (prepare_revision_walk(revs))\n \t\tdie(\"revision walk setup failed\");\n \n"},{"id":"142669","messageId":"AANLkTikHODw5irE-84bkztWhUKgP8v1PG9zTW1Ea6WRs@mail.gmail.com","threadId":"23958","inReplyTo":"20100531194240.28729.50475.chriscool@tuxfamily.org","subject":"Re: [PATCH 7/8] Documentation/cherry-pick: describe passing more than one commit","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2010-06-01T09:29:32Z","receivedAt":"2010-06-01T09:29:32Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Hi,\n\nChristian Couder <chriscool@tuxfamily.org> wrote:\n>  -n::\n>  --no-commit::\n> -       Usually the command automatically creates a commit.\n> -       This flag applies the change necessary to cherry-pick\n> -       the named commit to your working tree and the index,\n> -       but does not make the commit.  In addition, when this\n> -       option is used, your index does not have to match the\n> -       HEAD commit.  The cherry-pick is done against the\n> -       beginning state of your index.\n> +       Usually the command automatically creates some commits.  This\n> +       flag applies the change necessary to cherry-pick the named\n> +       commits to your working tree and the index, but does not make\n> +       the commits.  In addition, when this option is used, your\n> +       index does not have to match the HEAD commit.  The cherry-pick\n> +       is done against the beginning state of your index.\n>  +\n\nAvoid re-wrapping the text so it's easy to see the changes that you\nhave introduced in subsequent blames- you've just changed the word\n\"commit\" to \"commits\".\n\n> +Examples\n> +--------\n\nStyle nitpick: shouldn't the word \"Examples\" be in all-caps?\n\n-- Ram\n"},{"id":"142673","messageId":"20100601095124.GA1033@progeny.tock","threadId":"23958","inReplyTo":"20100531194240.28729.50475.chriscool@tuxfamily.org","subject":"Re: [PATCH 7/8] Documentation/cherry-pick: describe passing more than one commit","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-06-01T09:51:24Z","receivedAt":"2010-06-01T09:51:24Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Christian Couder wrote:\n\n> --- a/Documentation/git-cherry-pick.txt\n> +++ b/Documentation/git-cherry-pick.txt\n> @@ -3,24 +3,29 @@ git-cherry-pick(1)\n>  \n>  NAME\n>  ----\n> -git-cherry-pick - Apply the change introduced by an existing commit\n> +git-cherry-pick - Apply the change introduced by some existing commits\n\nMaybe s/change/changes/.\n\n>  DESCRIPTION\n>  -----------\n> -Given one existing commit, apply the change the patch introduces, and record a\n> -new commit that records it.  This requires your working tree to be clean (no\n> -modifications from the HEAD commit).\n> +\n> +Given one or more existing commits, apply the changes that the related\n> +patches introduce, and record some new commits that record them.  This\n> +requires your working tree to be clean (no modifications from the HEAD\n> +commit).\n\n\"Related\" made me think \"related how\"?  \"Record some new commits\"\nsounds oddly vague.\n\nMaybe:\n\n\tGiven one or more existing commits, apply the change each one\n\tintroduces, recording a new commit for each.  This requires\n\tyour working tree to be clean (no modifications from the HEAD\n\tcommit).\n\n>  OPTIONS\n>  -------\n> -<commit>::\n> -\tCommit to cherry-pick.\n> +<commit>...::\n> +\tCommits to cherry-pick.\n>  \tFor a more complete list of ways to spell commits, see the\n>  \t\"SPECIFYING REVISIONS\" section in linkgit:git-rev-parse[1].\n> +\tSets of commits can also be given but no traversal is done\n> +\tby default, see linkgit:git-rev-list[1] and its '--no-walk'\n> +\toption.\n\n--no-walk can be a bit confusing.  I think we should try to avoid\nrelying on the reader understanding it.\n\n <commit>...::\n\tCommits to cherry-pick.\n\tFor a more complete list of ways to spell commits, see the\n\t\"SPECIFYING REVISIONS\" section in linkgit:git-rev-parse[1].\n\tRevision ranges are interpreted as though specified with\n\tthe `--no-walk` option; see the \"Examples\" section below.\n\n>  -e::\n>  --edit::\n> @@ -55,13 +60,12 @@ OPTIONS\n>  \n>  -n::\n>  --no-commit::\n> -\tUsually the command automatically creates a commit.\n> -\tThis flag applies the change necessary to cherry-pick\n> -\tthe named commit to your working tree and the index,\n> -\tbut does not make the commit.  In addition, when this\n> -\toption is used, your index does not have to match the\n> -\tHEAD commit.  The cherry-pick is done against the\n> -\tbeginning state of your index.\n> +\tUsually the command automatically creates some commits.  This\n> +\tflag applies the change necessary to cherry-pick the named\n> +\tcommits to your working tree and the index, but does not make\n> +\tthe commits.  In addition, when this option is used, your\n> +\tindex does not have to match the HEAD commit.  The cherry-pick\n> +\tis done against the beginning state of your index.\n\nThis switches between singular and plural.\n\n -n::\n --no-commit::\n\tUsually 'git cherry-pick' automatically creates a sequence\n\tof commits.  This option can be used to apply the changes\n\tnecessary to cherry-pick each named commit to your working\n\ttree and index without making any commits.  In addition,\n\twhen this option is used, your index does not have to match\n\tthe HEAD commit: the cherry-pick is done against the\n\tbeginning state of the index.\n\n>  +\n>  This is useful when cherry-picking more than one commits'\n>  effect to your index in a row.\n\n\tThis is useful for cherry-picking multiple commits\n\tto produce a single new commit.\n\n> @@ -75,6 +79,38 @@ 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> +Examples\n> +--------\n\nThese are a little repetitive.\n\n> +git cherry-pick master::\n> +\n> +\tApply the changes specified by the commit pointed to by master\n> +\tand create a new commit with these changes.\n\ngit cherry-pick master::\n\n\tApply the change introduced by the commit at the tip of the\n\tmaster branch and create a new commit.\n\n> +\n> +git cherry-pick master~3..master::\n> +git cherry-pick ^master~3 master::\n> +\n> +\tApply the changes specified by the last 3 commits pointed to\n> +\tby master and create 3 new commits with these changes.\n\ngit cherry-pick ..master::\ngit cherry-pick ^HEAD master::\n\n\tApply the changes introduced by all commits that are ancestors\n\tof master but not HEAD to produce new commits on the current\n\tbranch.\n\n> +git cherry-pick master\\~3 master~2::\n> +\n> +\tApply the changes specified by the fourth and third last\n> +\tcommits pointed to by master and create 2 new commits with\n> +\tthese changes.\n\ngit cherry-pick master~5 master~2::\n\n\tApply the changes introduced by the fifth- and second-generation\n\tgrandparents of master to HEAD as new commits.\n\n> +\n> +git cherry-pick -n master~1 next::\n> +\n> +\tApply to the working tree and the index the changes specified\n> +\tby the second last commit pointed to by master and by the last\n> +\tcommit pointed to by next, but do not create any commit with\n> +\tthese changes.\n\ngit rev-list 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> +\n> +git cherry-pick --ff ..next::\n> +\n> +\tIf possible fast forward to the existing commits already in\n> +\tnext but not in HEAD, otherwise apply the changes specified by\n> +\tthese commits and create new commits with these changes.\n\ngit cherry-pick --ff ..next::\n\n\tIf history is linear and HEAD is an ancestor of next, update\n\tthe working tree and advance the HEAD pointer to match next.\n\tOtherwise, apply the changes introduced by those commits that\n\tare in next but not HEAD to the current branch, creating a new\n\tcommit for each new change.\n\n(This is not precisely right, since it doesn’t describe the behavior\nin some cases of nonlinear history:\n\n   . --- . --- . --- . ---. next\n  /                      /\n . HEAD             .---.\n\nIn this case, assuming time flows left-to-right, the HEAD would\nfast-forward three commits, then cherry-pick the other three.  Not\nsure how to word this nicely.)\n\nHope that helps,\nJonathan\n"},{"id":"142675","messageId":"AANLkTikjCFLj8ZxKI-kiLOqYDg9YYIkX8-lRxNATNGcO@mail.gmail.com","threadId":"23958","inReplyTo":"20100601095124.GA1033@progeny.tock","subject":"Re: [PATCH 7/8] Documentation/cherry-pick: describe passing more than one commit","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2010-06-01T10:26:01Z","receivedAt":"2010-06-01T10:26:01Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Hi,\n\nJonathan Nieder wrote:\n> Christian Couder wrote:\n>> +Examples\n>> +--------\n>\n> These are a little repetitive.\n\nSince you also posted an \"Examples\" section for the git-revert, you\ncould especially showcase options that aren't in git-revert (--ff and\n-x) here.\nAlso, you might want to include a reference to git-revert in this\ndocument, in a \"See Also\" section perhaps?\n\n-- Ram\n"},{"id":"142681","messageId":"AANLkTilu8C68FlLkNg_3wEjRRX25TaydZCve_P4r4_X7@mail.gmail.com","threadId":"23958","inReplyTo":"20100531194240.28729.15284.chriscool@tuxfamily.org","subject":"Re: [PATCH 8/8] Documentation/revert: describe passing more than one commit","fromName":"Antriksh Pany","fromEmail":"antriksh.pany@gmail.com","sentAt":"2010-06-01T13:28:57Z","receivedAt":"2010-06-01T13:28:57Z","isPatch":true,"sender":{"key":"antriksh.pany@gmail.com","avatar":null},"body":"On Mon, May 31, 2010 at 8:42 PM, Christian Couder\n<chriscool@tuxfamily.org> wrote:\n> And while at it, add an \"Examples\" section.\n>\n> Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n> ---\n>  Documentation/git-revert.txt |   52 ++++++++++++++++++++++++++++-------------\n>  1 files changed, 35 insertions(+), 17 deletions(-)\n>\n> diff --git a/Documentation/git-revert.txt b/Documentation/git-revert.txt\n> index c66bf80..5740f37 100644\n> --- a/Documentation/git-revert.txt\n> +++ b/Documentation/git-revert.txt\n> @@ -3,20 +3,22 @@ git-revert(1)\n>\n>  NAME\n>  ----\n> -git-revert - Revert an existing commit\n> +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] <commit>...\n>\n>  DESCRIPTION\n>  -----------\n> -Given one existing commit, revert the change the patch introduces, and record a\n> -new commit that records it.  This requires your working tree to be clean (no\n> -modifications from the HEAD commit).\n>\n> -Note: 'git revert' is used to record a new commit to reverse the\n> -effect of an earlier commit (often a faulty one).  If you want to\n> +Given one or more existing commits, revert the changes that the\n> +related patches introduce, and record some new commits that record\n> +them.  This requires your working tree to be clean (no modifications\n> +from the HEAD commit).\n> +\n> +Note: 'git revert' is used to record some new commits to reverse the\n> +effect of some earlier commits (often only a faulty one).  If you want to\n>  throw away all uncommitted changes in your working directory, you\n>  should see linkgit:git-reset[1], particularly the '--hard' option.  If\n>  you want to extract specific files as they were in another commit, you\n> @@ -26,10 +28,13 @@ both will discard uncommitted changes in your working directory.\n>\n>  OPTIONS\n>  -------\n> -<commit>::\n> -       Commit to revert.\n> +<commit>...::\n> +       Commits to revert.\n>        For a more complete list of ways to spell commit names, see\n>        \"SPECIFYING REVISIONS\" section in linkgit:git-rev-parse[1].\n> +       Sets of commits can also be given but no traversal is done by\n> +       default, see linkgit:git-rev-list[1] and its '--no-walk'\n> +       option.\n>\n>  -e::\n>  --edit::\n> @@ -59,14 +64,13 @@ more details.\n>\n>  -n::\n>  --no-commit::\n> -       Usually the command automatically creates a commit with\n> -       a commit log message stating which commit was\n> -       reverted.  This flag applies the change necessary\n> -       to revert the named commit to your working tree\n> -       and the index, but does not make the commit.  In addition,\n> -       when this option is used, your index does not have to match\n> -       the HEAD commit.  The revert is done against the\n> -       beginning state of your index.\n> +       Usually the command automatically creates some commits with\n> +       commit log messages stating which commits were reverted.  This\n> +       flag applies the changes necessary to revert the named commits\n> +       to your working tree and the index, but does not make the\n> +       commits.  In addition, when this option is used, your index\n> +       does not have to match the HEAD commit.  The revert is done\n> +       against the beginning state of your index.\n>  +\n>  This is useful when reverting more than one commits'\n>  effect to your index in a row.\n> @@ -75,6 +79,20 @@ effect to your index in a row.\n>  --signoff::\n>        Add Signed-off-by line at the end of the commit message.\n>\n> +Examples\n> +--------\n> +git revert HEAD~3::\n> +\n> +       Revert the changes specified by the fourth last commit in HEAD\n> +       and create a new commit with the reverted changes.\n> +\n> +git revert -n master\\~5..master~2::\n\nIs the backslash correct?\n\n> +\n> +       Revert the changes done by commits from the fiveth last commit\n\n'fifth' instead of 'fiveth' may be more appropriate :)\n\n> +       in master (included) to the third last commit in master\n> +       (included), but do not create any commit with the reverted\n> +       changes. The revert only modifies the working tree and the\n> +       index.\n>\n>  Author\n>  ------\n> --\n> 1.7.1.361.g42de.dirty\n>\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n>\n"},{"id":"142770","messageId":"201006020757.01726.chriscool@tuxfamily.org","threadId":"23958","inReplyTo":"20100601090317.GB32320@progeny.tock","subject":"Re: [PATCH 5/8] revert: allow cherry-picking more than one commit","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2010-06-02T05:57:01Z","receivedAt":"2010-06-02T05:57:01Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Tuesday 01 June 2010 11:03:17 Jonathan Nieder wrote:\n> Christian Couder wrote:\n> > --- a/builtin/revert.c\n> > +++ b/builtin/revert.c\n> > @@ -520,8 +516,33 @@ static int do_pick_commit()\n> >  \treturn 0;\n> >  }\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> > +\n> > +\tinit_revisions(revs, NULL);\n> > +\tsetup_revisions(argc - 1, argv, revs, NULL);\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> \n> Tiny one-time leak.  Maybe avoiding it will make debugging tools\n> happier.\n\nI added a \"free(argv)\".\n\nThanks,\nChristian.\n"},{"id":"142771","messageId":"201006020757.15117.chriscool@tuxfamily.org","threadId":"23958","inReplyTo":"AANLkTikHODw5irE-84bkztWhUKgP8v1PG9zTW1Ea6WRs@mail.gmail.com","subject":"Re: [PATCH 7/8] Documentation/cherry-pick: describe passing more than one commit","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2010-06-02T05:57:15Z","receivedAt":"2010-06-02T05:57:15Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Tuesday 01 June 2010 11:29:32 Ramkumar Ramachandra wrote:\n> Hi,\n> \n> Christian Couder <chriscool@tuxfamily.org> wrote:\n> >  -n::\n> >  --no-commit::\n> > -       Usually the command automatically creates a commit.\n> > -       This flag applies the change necessary to cherry-pick\n> > -       the named commit to your working tree and the index,\n> > -       but does not make the commit.  In addition, when this\n> > -       option is used, your index does not have to match the\n> > -       HEAD commit.  The cherry-pick is done against the\n> > -       beginning state of your index.\n> > +       Usually the command automatically creates some commits.  This\n> > +       flag applies the change necessary to cherry-pick the named\n> > +       commits to your working tree and the index, but does not make\n> > +       the commits.  In addition, when this option is used, your\n> > +       index does not have to match the HEAD commit.  The cherry-pick\n> > +       is done against the beginning state of your index.\n> >  +\n> \n> Avoid re-wrapping the text so it's easy to see the changes that you\n> have introduced in subsequent blames- you've just changed the word\n> \"commit\" to \"commits\".\n\nOk, avoided the re-wrapping.\n\n> > +Examples\n> > +--------\n> \n> Style nitpick: shouldn't the word \"Examples\" be in all-caps?\n\nI had a quick look at Documentation/*.txt and found 22 files with \"Examples\" \nand 32 files with \"EXAMPLES\", so I changed to \"EXAMPLES\". But if you really \ncare I suggest you to submit a patch to changes the 22 files that contains \n\"EXAMPLES\".\n\nThanks,\nChristian.\n"},{"id":"142772","messageId":"201006020757.34186.chriscool@tuxfamily.org","threadId":"23958","inReplyTo":"20100601095124.GA1033@progeny.tock","subject":"Re: [PATCH 7/8] Documentation/cherry-pick: describe passing more than one commit","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2010-06-02T05:57:34Z","receivedAt":"2010-06-02T05:57:34Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Tuesday 01 June 2010 11:51:24 Jonathan Nieder wrote:\n> Christian Couder wrote:\n> > --- a/Documentation/git-cherry-pick.txt\n> > +++ b/Documentation/git-cherry-pick.txt\n> > @@ -3,24 +3,29 @@ git-cherry-pick(1)\n> >\n> >  NAME\n> >  ----\n> > -git-cherry-pick - Apply the change introduced by an existing commit\n> > +git-cherry-pick - Apply the change introduced by some existing commits\n> \n> Maybe s/change/changes/.\n\nOk.\n\n> >  DESCRIPTION\n> >  -----------\n> > -Given one existing commit, apply the change the patch introduces, and\n> > record a -new commit that records it.  This requires your working tree to\n> > be clean (no -modifications from the HEAD commit).\n> > +\n> > +Given one or more existing commits, apply the changes that the related\n> > +patches introduce, and record some new commits that record them.  This\n> > +requires your working tree to be clean (no modifications from the HEAD\n> > +commit).\n> \n> \"Related\" made me think \"related how\"?  \"Record some new commits\"\n> sounds oddly vague.\n> \n> Maybe:\n> \n> \tGiven one or more existing commits, apply the change each one\n> \tintroduces, recording a new commit for each.  This requires\n> \tyour working tree to be clean (no modifications from the HEAD\n> \tcommit).\n\nOk.\n\n> >  OPTIONS\n> >  -------\n> > -<commit>::\n> > -\tCommit to cherry-pick.\n> > +<commit>...::\n> > +\tCommits to cherry-pick.\n> >  \tFor a more complete list of ways to spell commits, see the\n> >  \t\"SPECIFYING REVISIONS\" section in linkgit:git-rev-parse[1].\n> > +\tSets of commits can also be given but no traversal is done\n> > +\tby default, see linkgit:git-rev-list[1] and its '--no-walk'\n> > +\toption.\n> \n> --no-walk can be a bit confusing.  I think we should try to avoid\n> relying on the reader understanding it.\n> \n>  <commit>...::\n> \tCommits to cherry-pick.\n> \tFor a more complete list of ways to spell commits, see the\n> \t\"SPECIFYING REVISIONS\" section in linkgit:git-rev-parse[1].\n> \tRevision ranges are interpreted as though specified with\n> \tthe `--no-walk` option; see the \"Examples\" section below.\n\nI put the following:\n\n<commit>...::\n\tCommits to cherry-pick.\n\tFor a more complete list of ways to spell commits, see the\n\t\"SPECIFYING REVISIONS\" section in linkgit:git-rev-parse[1].\n\tSets of commits can be passed but no traversal is done by\n\tdefault, as if the '--no-walk' option was specified, see\n\tlinkgit:git-rev-list[1].\n\n> >  -e::\n> >  --edit::\n> > @@ -55,13 +60,12 @@ OPTIONS\n> >\n> >  -n::\n> >  --no-commit::\n> > -\tUsually the command automatically creates a commit.\n> > -\tThis flag applies the change necessary to cherry-pick\n> > -\tthe named commit to your working tree and the index,\n> > -\tbut does not make the commit.  In addition, when this\n> > -\toption is used, your index does not have to match the\n> > -\tHEAD commit.  The cherry-pick is done against the\n> > -\tbeginning state of your index.\n> > +\tUsually the command automatically creates some commits.  This\n> > +\tflag applies the change necessary to cherry-pick the named\n> > +\tcommits to your working tree and the index, but does not make\n> > +\tthe commits.  In addition, when this option is used, your\n> > +\tindex does not have to match the HEAD commit.  The cherry-pick\n> > +\tis done against the beginning state of your index.\n> \n> This switches between singular and plural.\n> \n>  -n::\n>  --no-commit::\n> \tUsually 'git cherry-pick' automatically creates a sequence\n> \tof commits.  This option can be used to apply the changes\n> \tnecessary to cherry-pick each named commit to your working\n> \ttree and index without making any commits.  In addition,\n> \twhen this option is used, your index does not have to match\n> \tthe HEAD commit: the cherry-pick is done against the\n> \tbeginning state of the index.\n\nI put the following:\n\n-n::\n--no-commit::\n\tUsually the command automatically creates a sequence of commits.\n\tThis flag applies the changes necessary to cherry-pick\n\teach named commit to your working tree and the index,\n\twithout making any commit.  In addition, when this\n\toption is used, your index does not have to match the\n\tHEAD commit.  The cherry-pick is done against the\n\tbeginning state of your index.\n\n> >  +\n> >  This is useful when cherry-picking more than one commits'\n> >  effect to your index in a row.\n> \n> \tThis is useful for cherry-picking multiple commits\n> \tto produce a single new commit.\n\nI don't think any change is really needed here, so I left it as it was.\n\n> > @@ -75,6 +79,38 @@ 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> > +Examples\n> > +--------\n> \n> These are a little repetitive.\n> \n> > +git cherry-pick master::\n> > +\n> > +\tApply the changes specified by the commit pointed to by master\n> > +\tand create a new commit with these changes.\n> \n> git cherry-pick master::\n> \n> \tApply the change introduced by the commit at the tip of the\n> \tmaster branch and create a new commit.\n\nI put:\n\ngit cherry-pick master::\n\n\tApply the change introduced by the commit at the tip of the\n\tmaster branch and create a new commit with this change.\n\n> > +\n> > +git cherry-pick master~3..master::\n> > +git cherry-pick ^master~3 master::\n> > +\n> > +\tApply the changes specified by the last 3 commits pointed to\n> > +\tby master and create 3 new commits with these changes.\n> \n> git cherry-pick ..master::\n> git cherry-pick ^HEAD master::\n> \n> \tApply the changes introduced by all commits that are ancestors\n> \tof master but not HEAD to produce new commits on the current\n> \tbranch.\n\nI put:\n\ngit cherry-pick ..master::\ngit cherry-pick ^HEAD master::\n\n\tApply the changes introduced by all commits that are ancestors\n\tof master but not of HEAD to produce new commits.\n\n\n> > +git cherry-pick master\\~3 master~2::\n> > +\n> > +\tApply the changes specified by the fourth and third last\n> > +\tcommits pointed to by master and create 2 new commits with\n> > +\tthese changes.\n> \n> git cherry-pick master~5 master~2::\n> \n> \tApply the changes introduced by the fifth- and second-generation\n> \tgrandparents of master to HEAD as new commits.\n\nI put:\n\ngit cherry-pick master\\~4 master~2::\n\n\tApply the changes introduced by the fifth and third last\n\tcommits pointed to by master and create 2 new commits with\n\tthese changes.\n \n> > +\n> > +git cherry-pick -n master~1 next::\n> > +\n> > +\tApply to the working tree and the index the changes specified\n> > +\tby the second last commit pointed to by master and by the last\n> > +\tcommit pointed to by next, but do not create any commit with\n> > +\tthese changes.\n> \n> git rev-list 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\nI think \"--reverse\" is needed after \"rev-list\" and cherry-pick has no --stdin \noption. So I put:\n\ngit cherry-pick -n master~1 next::\n\n\tApply to the working tree and the index the changes introduced\n\tby the second last commit pointed to by master and by the last\n\tcommit pointed to by next, but do not create any commit with\n\tthese changes.\n\n> > +\n> > +git cherry-pick --ff ..next::\n> > +\n> > +\tIf possible fast forward to the existing commits already in\n> > +\tnext but not in HEAD, otherwise apply the changes specified by\n> > +\tthese commits and create new commits with these changes.\n> \n> git cherry-pick --ff ..next::\n> \n> \tIf history is linear and HEAD is an ancestor of next, update\n> \tthe working tree and advance the HEAD pointer to match next.\n> \tOtherwise, apply the changes introduced by those commits that\n> \tare in next but not HEAD to the current branch, creating a new\n> \tcommit for each new change.\n\nOk.\n\nThanks,\nChristian.\n"},{"id":"142773","messageId":"201006020757.42629.chriscool@tuxfamily.org","threadId":"23958","inReplyTo":"AANLkTikjCFLj8ZxKI-kiLOqYDg9YYIkX8-lRxNATNGcO@mail.gmail.com","subject":"Re: [PATCH 7/8] Documentation/cherry-pick: describe passing more than one commit","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2010-06-02T05:57:42Z","receivedAt":"2010-06-02T05:57:42Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Hi,\n\nOn Tuesday 01 June 2010 12:26:01 Ramkumar Ramachandra wrote:\n> Hi,\n> \n> Jonathan Nieder wrote:\n> > Christian Couder wrote:\n> >> +Examples\n> >> +--------\n> >\n> > These are a little repetitive.\n> \n> Since you also posted an \"Examples\" section for the git-revert, you\n> could especially showcase options that aren't in git-revert (--ff and\n> -x) here.\n\nThere is already an example with --ff and I think -x may not deserve an \nexample. (But feel free to propose a patch to add one if you think it's worth \nit.)\n\n> Also, you might want to include a reference to git-revert in this\n> document, in a \"See Also\" section perhaps?\n\nOk, I added a \"SEE ALSO\" section to both git-cherry-pick.txt and git-\nrevert.txt.\n\nThanks,\nChristian.\n"},{"id":"142774","messageId":"201006020757.51575.chriscool@tuxfamily.org","threadId":"23958","inReplyTo":"AANLkTilu8C68FlLkNg_3wEjRRX25TaydZCve_P4r4_X7@mail.gmail.com","subject":"Re: [PATCH 8/8] Documentation/revert: describe passing more than one commit","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2010-06-02T05:57:51Z","receivedAt":"2010-06-02T05:57:51Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Tuesday 01 June 2010 15:28:57 Antriksh Pany wrote:\n> \n> > +git revert -n master\\~5..master~2::\n> \n> Is the backslash correct?\n\nYes, otherwise asciidoc does something strange with the text between both \"~\".\n\n> > +\n> > +       Revert the changes done by commits from the fiveth last commit\n> \n> 'fifth' instead of 'fiveth' may be more appropriate :)\n\nYes!\n\nThanks,\nChristian.\n"},{"id":"142784","messageId":"20100602061452.GA9439@progeny.tock","threadId":"23958","inReplyTo":"201006020757.34186.chriscool@tuxfamily.org","subject":"Re: [PATCH 7/8] Documentation/cherry-pick: describe passing more than one commit","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-06-02T06:14:52Z","receivedAt":"2010-06-02T06:14:52Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Christian Couder wrote:\n> On Tuesday 01 June 2010 11:51:24 Jonathan Nieder wrote:\n\n>> git rev-list 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> I think \"--reverse\" is needed after \"rev-list\" and cherry-pick has no --stdin \n> option.\n\nThat’s too bad. :(  git show inherits it from rev-list.\n\nYour new series looks good.  Maybe I will obfuscate the examples some\nother day.\n\nThanks,\nJonathan\n"},{"id":"142847","messageId":"7vwruh9fbj.fsf@alter.siamese.dyndns.org","threadId":"23958","inReplyTo":"20100601083549.GA28377@progeny.tock","subject":"Re: [PATCH 5/8] revert: allow cherry-picking more than one commit","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-06-02T23:37:20Z","receivedAt":"2010-06-02T23:37:20Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonathan Nieder <jrnieder@gmail.com> writes:\n\n> As a side effect, this unfortunately changes the meaning of\n> ‘git log --oneline --decorate --no-walk -5 --all’: instead of listing\n> five refs, after this patch that command would list the five most\n> recent commits.\n\nIt indeed is a change in behaviour, but in this case it is probably not\nsuch a big deal.\n\nThe order \"--all\" (or \"--branches\" for that matter) lists refs doesn't\nhave any logical relationship with the order of importance from the end\nuser's point of view (they're just alphabetical), and asking for \"first\nfive\" won't make much sense unless you are learning or testing the\ncombinations of options, i.e. not in real life, I think.\n\nThanks.\n"},{"id":"142855","messageId":"201006030618.26838.chriscool@tuxfamily.org","threadId":"23958","inReplyTo":"7vwruh9fbj.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 5/8] revert: allow cherry-picking more than one commit","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2010-06-03T04:18:26Z","receivedAt":"2010-06-03T04:18:26Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Thursday 03 June 2010 01:37:20 Junio C Hamano wrote:\n> Jonathan Nieder <jrnieder@gmail.com> writes:\n> > As a side effect, this unfortunately changes the meaning of\n> > ‘git log --oneline --decorate --no-walk -5 --all’: instead of listing\n> > five refs, after this patch that command would list the five most\n> > recent commits.\n> \n> It indeed is a change in behaviour, but in this case it is probably not\n> such a big deal.\n>\n> The order \"--all\" (or \"--branches\" for that matter) lists refs doesn't\n> have any logical relationship with the order of importance from the end\n> user's point of view (they're just alphabetical), and asking for \"first\n> five\" won't make much sense unless you are learning or testing the\n> combinations of options, i.e. not in real life, I think.\n\nI agree and I think Jonathan's patch would be nice to have.\n\nThanks both,\nChristian.\n"},{"id":"143625","messageId":"201006140533.10649.chriscool@tuxfamily.org","threadId":"23958","inReplyTo":"20100602061452.GA9439@progeny.tock","subject":"Re: [PATCH 7/8] Documentation/cherry-pick: describe passing more than one commit","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2010-06-14T03:33:10Z","receivedAt":"2010-06-14T03:33:10Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Wednesday 02 June 2010 08:14:52 Jonathan Nieder wrote:\n> Christian Couder wrote:\n> > On Tuesday 01 June 2010 11:51:24 Jonathan Nieder wrote:\n> >> git rev-list 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> > I think \"--reverse\" is needed after \"rev-list\" and cherry-pick has no\n> > --stdin option.\n> \n> That’s too bad. :(  git show inherits it from rev-list.\n> \n> Your new series looks good.  Maybe I will obfuscate the examples some\n> other day.\n\nI will send a patch to add option --stdin to revert/cherry-pick. And it adds \nyour fixed obfuscating example :-)\n\nThanks,\nChristian.\n"}]}