summaryrefslogtreecommitdiff
path: root/builtin/revert.c
diff options
context:
space:
mode:
authorChristian Couder <chriscool@tuxfamily.org>2010-07-14 01:28:13 +0200
committerJunio C Hamano <gitster@pobox.com>2010-07-16 15:21:52 -0700
commit5df16453d4da41e5a36de536acf9acc8aab98041 (patch)
tree1e45be4a3344eb1abfd704aeb89a58e94a42770f /builtin/revert.c
parent7b53b92fdb22b90d2be558db84c725641c4ad170 (diff)
downloadgit-5df16453d4da41e5a36de536acf9acc8aab98041.tar.gz
revert: refactor commit code into a new run_git_commit() function
Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/revert.c')
-rw-r--r--builtin/revert.c52
1 files changed, 27 insertions, 25 deletions
diff --git a/builtin/revert.c b/builtin/revert.c
index b082bb425c..b84b5b8645 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -361,6 +361,32 @@ static int do_recursive_merge(struct commit *base, struct commit *next,
return !clean;
}
+/*
+ * If we are cherry-pick, and if the merge did not result in
+ * hand-editing, we will hit this commit and inherit the original
+ * author date and name.
+ * If we are revert, or if our cherry-pick results in a hand merge,
+ * we had better say that the current user is responsible for that.
+ */
+static int run_git_commit(const char *defmsg)
+{
+ /* 6 is max possible length of our args array including NULL */
+ const char *args[6];
+ int i = 0;
+
+ args[i++] = "commit";
+ args[i++] = "-n";
+ if (signoff)
+ args[i++] = "-s";
+ if (!edit) {
+ args[i++] = "-F";
+ args[i++] = defmsg;
+ }
+ args[i] = NULL;
+
+ return run_command_v_opt(args, RUN_GIT_CMD);
+}
+
static int do_pick_commit(void)
{
unsigned char head[20];
@@ -501,33 +527,9 @@ static int do_pick_commit(void)
if (res)
return 1;
- /*
- *
- * If we are cherry-pick, and if the merge did not result in
- * hand-editing, we will hit this commit and inherit the original
- * author date and name.
- * If we are revert, or if our cherry-pick results in a hand merge,
- * we had better say that the current user is responsible for that.
- */
-
if (!no_commit) {
- /* 6 is max possible length of our args array including NULL */
- const char *args[6];
- int res;
- int i = 0;
-
- args[i++] = "commit";
- args[i++] = "-n";
- if (signoff)
- args[i++] = "-s";
- if (!edit) {
- args[i++] = "-F";
- args[i++] = defmsg;
- }
- args[i] = NULL;
- res = run_command_v_opt(args, RUN_GIT_CMD);
+ res = run_git_commit(defmsg);
free(defmsg);
-
return res;
}