{"thread":{"id":"24401","subject":"[PATCH 2/4] revert: refactor commit code into a new run_git_commit() function","startedAt":"2010-07-13T23:28:13Z","lastAt":"2010-07-13T23:28:13Z","messageCount":1,"participants":["Christian Couder"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"145610","messageId":"20100713232816.7738.67812.chriscool@tuxfamily.org","threadId":"24401","inReplyTo":null,"subject":"[PATCH 2/4] revert: refactor commit code into a new run_git_commit() function","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2010-07-13T23:28:13Z","receivedAt":"2010-07-13T23:28:13Z","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 builtin/revert.c |   52 +++++++++++++++++++++++++++-------------------------\n 1 files changed, 27 insertions(+), 25 deletions(-)\n\ndiff --git a/builtin/revert.c b/builtin/revert.c\nindex b082bb4..b84b5b8 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@@ -501,33 +527,9 @@ static int do_pick_commit(void)\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\tres = run_git_commit(defmsg);\n \t\tfree(defmsg);\n-\n \t\treturn res;\n \t}\n \n-- \n1.7.2.rc1.215.g2dff2.dirty\n"}]}