{"thread":{"id":"24374","subject":"[PATCH 2/2] revert: don't print \"Finished one cherry-pick.\" if commit failed","startedAt":"2010-07-12T11:54:54Z","lastAt":"2010-07-13T21:06:33Z","messageCount":3,"participants":["Christian Couder","Jonathan Nieder"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"145367","messageId":"20100712115455.12251.47449.chriscool@tuxfamily.org","threadId":"24374","inReplyTo":null,"subject":"[PATCH 2/2] revert: don't print \"Finished one cherry-pick.\" if commit failed","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2010-07-12T11:54:54Z","receivedAt":"2010-07-12T11:54:54Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"And, while at it, refactor commit code into a new run_git_commit()\nfunction.\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/revert.c |   67 +++++++++++++++++++++++++-----------------------------\n 1 files changed, 31 insertions(+), 36 deletions(-)\n\ndiff --git a/builtin/revert.c b/builtin/revert.c\nindex b082bb4..ec931bd 100644\n--- a/builtin/revert.c\n+++ b/builtin/revert.c\n@@ -361,6 +361,32 @@ static int do_recursive_merge(struct commit *base, struct commit *next,\n \treturn !clean;\n }\n \n+/*\n+ * If we are cherry-pick, and if the merge did not result in\n+ * hand-editing, we will hit this commit and inherit the original\n+ * author date and name.\n+ * If we are revert, or if our cherry-pick results in a hand merge,\n+ * we had better say that the current user is responsible for that.\n+ */\n+static int run_git_commit(const char *defmsg)\n+{\n+\t/* 6 is max possible length of our args array including NULL */\n+\tconst char *args[6];\n+\tint i = 0;\n+\n+\targs[i++] = \"commit\";\n+\targs[i++] = \"-n\";\n+\tif (signoff)\n+\t\targs[i++] = \"-s\";\n+\tif (!edit) {\n+\t\targs[i++] = \"-F\";\n+\t\targs[i++] = defmsg;\n+\t}\n+\targs[i] = NULL;\n+\n+\treturn run_command_v_opt(args, RUN_GIT_CMD);\n+}\n+\n static int do_pick_commit(void)\n {\n \tunsigned char head[20];\n@@ -492,48 +518,17 @@ static int do_pick_commit(void)\n \t\t\tmebuf.buf, help_msg());\n \t\trerere(allow_rerere_auto);\n \t} else {\n-\t\tfprintf(stderr, \"Finished one %s.\\n\", mebuf.buf);\n+\t\tif (!no_commit)\n+\t\t\tres = run_git_commit(defmsg);\n+\t\tif (!res)\n+\t\t\tfprintf(stderr, \"Finished one %s.\\n\", mebuf.buf);\n \t}\n \n \tstrbuf_release(&mebuf);\n \tfree_message(&msg);\n-\n-\tif (res)\n-\t\treturn 1;\n-\n-\t/*\n-\t *\n-\t * If we are cherry-pick, and if the merge did not result in\n-\t * hand-editing, we will hit this commit and inherit the original\n-\t * author date and name.\n-\t * If we are revert, or if our cherry-pick results in a hand merge,\n-\t * we had better say that the current user is responsible for that.\n-\t */\n-\n-\tif (!no_commit) {\n-\t\t/* 6 is max possible length of our args array including NULL */\n-\t\tconst char *args[6];\n-\t\tint res;\n-\t\tint i = 0;\n-\n-\t\targs[i++] = \"commit\";\n-\t\targs[i++] = \"-n\";\n-\t\tif (signoff)\n-\t\t\targs[i++] = \"-s\";\n-\t\tif (!edit) {\n-\t\t\targs[i++] = \"-F\";\n-\t\t\targs[i++] = defmsg;\n-\t\t}\n-\t\targs[i] = NULL;\n-\t\tres = run_command_v_opt(args, RUN_GIT_CMD);\n-\t\tfree(defmsg);\n-\n-\t\treturn res;\n-\t}\n-\n \tfree(defmsg);\n \n-\treturn 0;\n+\treturn res;\n }\n \n static void prepare_revs(struct rev_info *revs)\n-- \n1.7.2.rc1.213.gf3fb81\n"},{"id":"145375","messageId":"20100712163934.GA1869@burratino","threadId":"24374","inReplyTo":"20100712115455.12251.47449.chriscool@tuxfamily.org","subject":"Re: [PATCH 2/2] revert: don't print \"Finished one cherry-pick.\" if commit failed","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-07-12T16:39:35Z","receivedAt":"2010-07-12T16:39:35Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Christian Couder wrote:\n\n> And, while at it, refactor commit code into a new run_git_commit()\n> function.\n\nProbably should be two patches.\n\n> +++ b/builtin/revert.c\n> @@ -492,48 +518,17 @@ static int do_pick_commit(void)\n>  \t\t\tmebuf.buf, help_msg());\n>  \t\trerere(allow_rerere_auto);\n>  \t} else {\n> -\t\tfprintf(stderr, \"Finished one %s.\\n\", mebuf.buf);\n> +\t\tif (!no_commit)\n> +\t\t\tres = run_git_commit(defmsg);\n> +\t\tif (!res)\n> +\t\t\tfprintf(stderr, \"Finished one %s.\\n\", mebuf.buf);\n>  \t}\n\nAck for this part.  Thanks.\n"},{"id":"145463","messageId":"201007132306.33828.chriscool@tuxfamily.org","threadId":"24374","inReplyTo":"20100712163934.GA1869@burratino","subject":"Re: [PATCH 2/2] revert: don't print \"Finished one cherry-pick.\" if commit failed","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2010-07-13T21:06:33Z","receivedAt":"2010-07-13T21:06:33Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Monday 12 July 2010 18:39:35 Jonathan Nieder wrote:\n> Christian Couder wrote:\n> > And, while at it, refactor commit code into a new run_git_commit()\n> > function.\n> \n> Probably should be two patches.\n\nOk, I will split it in two patches.\n\n> > +++ b/builtin/revert.c\n> > @@ -492,48 +518,17 @@ static int do_pick_commit(void)\n> > \n> >  \t\t\tmebuf.buf, help_msg());\n> >  \t\t\n> >  \t\trerere(allow_rerere_auto);\n> >  \t\n> >  \t} else {\n> > \n> > -\t\tfprintf(stderr, \"Finished one %s.\\n\", mebuf.buf);\n> > +\t\tif (!no_commit)\n> > +\t\t\tres = run_git_commit(defmsg);\n> > +\t\tif (!res)\n> > +\t\t\tfprintf(stderr, \"Finished one %s.\\n\", mebuf.buf);\n> > \n> >  \t}\n> \n> Ack for this part.  Thanks.\n\nThanks,\nChristian.\n"}]}