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>
This commit is contained in:
Junio C Hamano
2009-11-03 06:59:18 -08:00
parent 63d564b300
commit 8b3dce5650
7 changed files with 20 additions and 22 deletions

View File

@ -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) {