diff options
author | Junio C Hamano <gitster@pobox.com> | 2009-11-03 06:59:18 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-11-20 15:10:29 -0800 |
commit | 8b3dce565084c89ceb19f7ccf0fe22ffd365f7fd (patch) | |
tree | 8af65ea645a32792642903fac65a4d776aa2408f /revision.c | |
parent | 63d564b300274ec71a274f9b672366d07ae5620a (diff) | |
download | git-8b3dce565084c89ceb19f7ccf0fe22ffd365f7fd.tar.gz git-8b3dce565084c89ceb19f7ccf0fe22ffd365f7fd.tar.xz |
Teach --stdin option to "log" family
Move the logic to read revs from standard input that rev-list knows about
from it to revision machinery, so that all the users of setup_revisions()
can feed the list of revs from the standard input when "--stdin" is used
on the command line.
Allow some users of the revision machinery that want different semantics
from the "--stdin" option to disable it by setting an option in the
rev_info structure.
This also cleans up the kludge made to bundle.c via cut and paste.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'revision.c')
-rw-r--r-- | revision.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/revision.c b/revision.c index d56387fe6..f5b735fc1 100644 --- a/revision.c +++ b/revision.c @@ -953,7 +953,7 @@ int handle_revision_arg(const char *arg, struct rev_info *revs, return 0; } -void read_revisions_from_stdin(struct rev_info *revs) +static void read_revisions_from_stdin(struct rev_info *revs) { struct strbuf sb; @@ -1229,7 +1229,7 @@ void parse_revision_opt(struct rev_info *revs, struct parse_opt_ctx_t *ctx, */ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const char *def) { - int i, flags, left, seen_dashdash; + int i, flags, left, seen_dashdash, read_from_stdin; /* First, search for "--" */ seen_dashdash = 0; @@ -1247,6 +1247,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch /* Second, deal with arguments and options */ flags = 0; + read_from_stdin = 0; for (left = i = 1; i < argc; i++) { const char *arg = argv[i]; if (*arg == '-') { @@ -1285,6 +1286,16 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch revs->no_walk = 0; continue; } + if (!strcmp(arg, "--stdin")) { + if (revs->disable_stdin) { + argv[left++] = arg; + continue; + } + if (read_from_stdin++) + die("--stdin given twice?"); + read_revisions_from_stdin(revs); + continue; + } opts = handle_revision_opt(revs, argc - i, argv + i, &left, argv); if (opts > 0) { |