git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Adam Brewster <adambrewster@gmail.com>
Cc: git@vger.kernel.org, gitster@pobox.com, mdl123@verizon.net,
	Johannes.Schindelin@gmx.de, jnareb@gmail.com,
	vmiklos@frugalware.org
Subject: Re: [PATCH v5]
Date: Sat, 05 Jul 2008 18:50:12 -0700	[thread overview]
Message-ID: <7vskunpyqz.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <1215293200-28199-1-git-send-email-adambrewster@gmail.com> (Adam Brewster's message of "Sat, 5 Jul 2008 17:26:38 -0400")

Adam Brewster <adambrewster@gmail.com> writes:

> The real reason read_revisions_from_stdin moved to revision.c is because I was 
> asked to do it that way.

Yeah, it is simply a bad taste to use helper in builtin-A from builtin-B.
More library-ish files such as revision.c are better home for utility
functions to be shared between builtins and commands.

Here is what I queued.

By the way did you compile test your fix before sending?

-- >8 --
Move read_revisions_from_stdin from builtin-rev-list.c to revision.c

Reading rev-list parameters from the command line can be reused by
commands other than rev-list.  Move this function to more "library-ish"
place to promote code reuse.

Signed-off-by: Adam Brewster <asb@bu.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

diff --git a/builtin-rev-list.c b/builtin-rev-list.c
index 83a7b13..54b6672 100644
--- a/builtin-rev-list.c
+++ b/builtin-rev-list.c
@@ -565,23 +565,6 @@ static struct commit_list *find_bisection(struct commit_list *list,
 	return best;
 }
 
-static void read_revisions_from_stdin(struct rev_info *revs)
-{
-	char line[1000];
-
-	while (fgets(line, sizeof(line), stdin) != NULL) {
-		int len = strlen(line);
-		if (len && line[len - 1] == '\n')
-			line[--len] = 0;
-		if (!len)
-			break;
-		if (line[0] == '-')
-			die("options not supported in --stdin mode");
-		if (handle_revision_arg(line, revs, 0, 1))
-			die("bad revision '%s'", line);
-	}
-}
-
 int cmd_rev_list(int argc, const char **argv, const char *prefix)
 {
 	struct commit_list *list;
diff --git a/revision.c b/revision.c
index fc66755..6ce6042 100644
--- a/revision.c
+++ b/revision.c
@@ -910,6 +910,23 @@ int handle_revision_arg(const char *arg, struct rev_info *revs,
 	return 0;
 }
 
+void read_revisions_from_stdin(struct rev_info *revs)
+{
+	char line[1000];
+
+	while (fgets(line, sizeof(line), stdin) != NULL) {
+		int len = strlen(line);
+		if (len && line[len - 1] == '\n')
+			line[--len] = '\0';
+		if (!len)
+			break;
+		if (line[0] == '-')
+			die("options not supported in --stdin mode");
+		if (handle_revision_arg(line, revs, 0, 1))
+			die("bad revision '%s'", line);
+	}
+}
+
 static void add_grep(struct rev_info *revs, const char *ptn, enum grep_pat_token what)
 {
 	if (!revs->grep_filter) {
diff --git a/revision.h b/revision.h
index abce500..83f364a 100644
--- a/revision.h
+++ b/revision.h
@@ -111,6 +111,8 @@ struct rev_info {
 #define REV_TREE_DIFFERENT	2
 
 /* revision.c */
+void read_revisions_from_stdin(struct rev_info *revs);
+
 typedef void (*show_early_output_fn_t)(struct rev_info *, struct commit_list *);
 volatile show_early_output_fn_t show_early_output;
 

  parent reply	other threads:[~2008-07-06  1:51 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-05 16:30 [PATCH/v3] bundle.c: added --stdin option to git-bundle Adam Brewster
2008-07-05 16:54 ` Jakub Narebski
2008-07-05 18:15 ` Junio C Hamano
2008-07-05 20:40   ` [PATCH v4 0/3] Adam Brewster
2008-07-05 20:40     ` [PATCH] Move read_revisions_from_stdin from builtin-rev-list.c to revision.c Adam Brewster
2008-07-05 20:40       ` [PATCH] git-bundle: add --stdin Adam Brewster
2008-07-05 20:40         ` [PATCH] Add git-basis.perl to contrib directory Adam Brewster
2008-07-05 20:48       ` [PATCH] Move read_revisions_from_stdin from builtin-rev-list.c to revision.c Miklos Vajna
2008-07-05 21:26         ` [PATCH v5] Adam Brewster
2008-07-05 21:26           ` [PATCH] Move read_revisions_from_stdin from builtin-rev-list.c to revision.c Adam Brewster
2008-07-05 21:26             ` [PATCH] git-bundle: add --stdin Adam Brewster
2008-07-06  0:57               ` Teach git-bundle to read revision arguments from stdin like git-rev-list Junio C Hamano
2008-07-06 14:28                 ` Adam Brewster
2008-07-06 14:28                   ` [PATCH] git-rev-list: tolerate multiple --stdin options Adam Brewster
2008-07-06 14:28                     ` [PATCH] Teach git-bundle to read revision arguments from stdin like Adam Brewster
2008-07-06  1:50           ` Junio C Hamano [this message]
2008-07-06  2:49             ` [PATCH v5] Adam Brewster
2008-07-06  0:57         ` [PATCH] Move read_revisions_from_stdin from builtin-rev-list.c to revision.c Junio C Hamano

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

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

  git send-email \
    --in-reply-to=7vskunpyqz.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=adambrewster@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=jnareb@gmail.com \
    --cc=mdl123@verizon.net \
    --cc=vmiklos@frugalware.org \
    /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.
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).