git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/4] revert: refactor commit code into a new run_git_commit() function
@ 2010-07-13 23:28 Christian Couder
  0 siblings, 0 replies; only message in thread
From: Christian Couder @ 2010-07-13 23:28 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: git, Johannes Schindelin, Sverre Rabbelier, Ramkumar Ramachandra,
	Jonathan Nieder, Jeff King


Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 builtin/revert.c |   52 +++++++++++++++++++++++++++-------------------------
 1 files changed, 27 insertions(+), 25 deletions(-)

diff --git a/builtin/revert.c b/builtin/revert.c
index b082bb4..b84b5b8 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;
 	}
 
-- 
1.7.2.rc1.215.g2dff2.dirty

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2010-07-15  9:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-13 23:28 [PATCH 2/4] revert: refactor commit code into a new run_git_commit() function Christian Couder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).