@matheusbsbs / matheus-bagliano / commits / 1fc561d169
Fork 0

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>

Adam Brewster committed Jul 5, 2008 at 17:26 UTC 1fc561d169ac08c411e34a4439894c5201b3d080
3 files changed +19 -17
builtin-rev-list.c
-17
@@ -565,23 +565,6 @@ static struct commit_list *find_bisection(struct commit_list *list,
565 return best;
566 }
567
568 -static void read_revisions_from_stdin(struct rev_info *revs)
569 -{
570 - char line[1000];
571 -
572 - while (fgets(line, sizeof(line), stdin) != NULL) {
573 - int len = strlen(line);
574 - if (len && line[len - 1] == '\n')
575 - line[--len] = 0;
576 - if (!len)
577 - break;
578 - if (line[0] == '-')
579 - die("options not supported in --stdin mode");
580 - if (handle_revision_arg(line, revs, 0, 1))
581 - die("bad revision '%s'", line);
582 - }
583 -}
584 -
568 int cmd_rev_list(int argc, const char **argv, const char *prefix)
569 {
570 struct commit_list *list;
revision.c
+17
@@ -910,6 +910,23 @@ int handle_revision_arg(const char *arg, struct rev_info *revs,
910 return 0;
911 }
912
913 +void read_revisions_from_stdin(struct rev_info *revs)
914 +{
915 + char line[1000];
916 +
917 + while (fgets(line, sizeof(line), stdin) != NULL) {
918 + int len = strlen(line);
919 + if (len && line[len - 1] == '\n')
920 + line[--len] = '\0';
921 + if (!len)
922 + break;
923 + if (line[0] == '-')
924 + die("options not supported in --stdin mode");
925 + if (handle_revision_arg(line, revs, 0, 1))
926 + die("bad revision '%s'", line);
927 + }
928 +}
929 +
930 static void add_grep(struct rev_info *revs, const char *ptn, enum grep_pat_token what)
931 {
932 if (!revs->grep_filter) {
revision.h
+2
@@ -111,6 +111,8 @@ struct rev_info {
111 #define REV_TREE_DIFFERENT 2
112
113 /* revision.c */
114 +void read_revisions_from_stdin(struct rev_info *revs);
115 +
116 typedef void (*show_early_output_fn_t)(struct rev_info *, struct commit_list *);
117 volatile show_early_output_fn_t show_early_output;
118