git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Kristian Høgsberg" <krh@redhat.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 6/7] Export rerere() and launch_editor().
Date: Wed, 19 Sep 2007 16:52:04 -0700	[thread overview]
Message-ID: <7vr6kunrh7.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <1190074016669-git-send-email-krh@redhat.com> (Kristian Høgsberg's message of "Mon, 17 Sep 2007 20:06:47 -0400")

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

> +/* Export for builtin-commit. */
> +int rerere(void)
> +{
> +	struct path_list merge_rr = { NULL, 0, 0, 1 };
> +	int fd;
> +
> +	git_config(git_rerere_config);
> +	if (!is_rerere_enabled())
> +		return 0;
> +
> +	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);
> +	return do_plain_rerere(&merge_rr, fd);
> +}

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);

  parent reply	other threads:[~2007-09-19 23:52 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-18  0:06 [PATCH 1/7] Enable wt-status output to a given FILE pointer Kristian Høgsberg
2007-09-18  0:06 ` [PATCH 2/7] Enable wt-status to run against non-standard index file Kristian Høgsberg
2007-09-18  0:06   ` [PATCH 3/7] Introduce entry point for launching add--interactive Kristian Høgsberg
2007-09-18  0:06     ` [PATCH 4/7] Clean up stripspace a bit, use strbuf even more Kristian Høgsberg
2007-09-18  0:06       ` [PATCH 5/7] Add strbuf_read_file() Kristian Høgsberg
2007-09-18  0:06         ` [PATCH 6/7] Export rerere() and launch_editor() Kristian Høgsberg
2007-09-18  0:06           ` [PATCH 7/7] Implement git commit as a builtin command Kristian Høgsberg
2007-09-18 13:58             ` Johannes Schindelin
2007-09-18 15:07               ` Kristian Høgsberg
2007-09-20  1:27             ` Junio C Hamano
2007-09-21 17:18               ` Kristian Høgsberg
2007-09-21 19:32                 ` Junio C Hamano
2007-09-24 20:27                   ` Kristian Høgsberg
2007-09-18 13:14           ` [PATCH 6/7] Export rerere() and launch_editor() Johannes Schindelin
2007-09-19 23:52           ` Junio C Hamano [this message]
2007-09-21 18:01             ` Kristian Høgsberg
2007-09-18 13:12       ` [PATCH 4/7] Clean up stripspace a bit, use strbuf even more Johannes Schindelin
2007-09-18 13:52         ` Kristian Høgsberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vr6kunrh7.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=krh@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).