diff options
author | Adam Brewster <adambrewster@gmail.com> | 2008-07-05 17:26:39 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-07-05 17:30:58 -0700 |
commit | 1fc561d169ac08c411e34a4439894c5201b3d080 (patch) | |
tree | 9836dceaa29f8f504fc48cd6ef1ca3809183b9e8 /revision.c | |
parent | 6e1c23442a0315ad440bb8457703dcf1ad943b96 (diff) | |
download | git-1fc561d169ac08c411e34a4439894c5201b3d080.tar.gz git-1fc561d169ac08c411e34a4439894c5201b3d080.tar.xz |
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>
Diffstat (limited to 'revision.c')
-rw-r--r-- | revision.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/revision.c b/revision.c index fc6675525..6ce6042a6 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) { |