Re: [PATCH 6/7] Export rerere() and launch_editor().

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Junio C Hamano
Date: Wednesday, September 19, 2007 - 4:52 pm

Kristian Høgsberg <krh@redhat.com> writes:


Is it just me who sees a suboptimal cut and paste here?

BTW, [1-5/7] look good so far.

diff --git a/builtin-rerere.c b/builtin-rerere.c
index 29d057c..2f51ae0 100644
--- a/builtin-rerere.c
+++ b/builtin-rerere.c
@@ -415,18 +415,39 @@ static int is_rerere_enabled(void)
 	return 1;
 }
 
-int cmd_rerere(int argc, const char **argv, const char *prefix)
+static int setup_rerere(struct path_list *merge_rr)
 {
-	struct path_list merge_rr = { NULL, 0, 0, 1 };
-	int i, fd = -1;
+	int fd;
 
 	git_config(git_rerere_config);
 	if (!is_rerere_enabled())
-		return 0;
+		return -1;
 
 	merge_rr_path = xstrdup(git_path("rr-cache/MERGE_RR"));
 	fd = hold_lock_file_for_update(&write_lock, merge_rr_path, 1);
-	read_rr(&merge_rr);
+	read_rr(merge_rr);
+	return fd;
+}
+
+int rerere(void)
+{
+	struct path_list merge_rr = { NULL, 0, 0, 1 };
+	int fd;
+
+	fd = setup_rerere(&merge_rr);
+	if (fd < 0)
+		return 0;
+	return do_plain_rerere(&merge_rr, fd);
+}
+
+int cmd_rerere(int argc, const char **argv, const char *prefix)
+{
+	struct path_list merge_rr = { NULL, 0, 0, 1 };
+	int i, fd;
+
+	fd = setup_rerere(&merge_rr);
+	if (fd < 0)
+		return 0;
 
 	if (argc < 2)
 		return do_plain_rerere(&merge_rr, fd);
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 6/7] Export rerere() and launch_editor()., Kristian Høgsberg, (Mon Sep 17, 5:06 pm)
[PATCH 7/7] Implement git commit as a builtin command., Kristian Høgsberg, (Mon Sep 17, 5:06 pm)
Re: [PATCH 6/7] Export rerere() and launch_editor()., Johannes Schindelin, (Tue Sep 18, 6:14 am)
Re: [PATCH 7/7] Implement git commit as a builtin command., Johannes Schindelin, (Tue Sep 18, 6:58 am)
Re: [PATCH 6/7] Export rerere() and launch_editor()., Junio C Hamano, (Wed Sep 19, 4:52 pm)
Re: [PATCH 7/7] Implement git commit as a builtin command., Junio C Hamano, (Wed Sep 19, 6:27 pm)
Re: [PATCH 6/7] Export rerere() and launch_editor()., Kristian , (Fri Sep 21, 11:01 am)
Re: [PATCH 7/7] Implement git commit as a builtin command., Junio C Hamano, (Fri Sep 21, 12:32 pm)