diff options
-rw-r--r-- | builtin/rev-list.c | 2 | ||||
-rw-r--r-- | revision.c | 5 | ||||
-rw-r--r-- | revision.h | 5 | ||||
-rwxr-xr-x | t/t6018-rev-list-glob.sh | 2 |
4 files changed, 9 insertions, 5 deletions
diff --git a/builtin/rev-list.c b/builtin/rev-list.c index 6fcb0ff6d5..475cfcf6df 100644 --- a/builtin/rev-list.c +++ b/builtin/rev-list.c @@ -493,7 +493,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix) if ((!revs.commits && reflog_walk_empty(revs.reflog_info) && (!(revs.tag_objects || revs.tree_objects || revs.blob_objects) && !revs.pending.nr) && - !revs.rev_input_given) || + !revs.rev_input_given && !revs.read_from_stdin) || revs.diff) usage(rev_list_usage); diff --git a/revision.c b/revision.c index a2570397b6..7fbdb18f26 100644 --- a/revision.c +++ b/revision.c @@ -2315,7 +2315,7 @@ static void NORETURN diagnose_missing_default(const char *def) */ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct setup_revision_opt *opt) { - int i, flags, left, seen_dashdash, read_from_stdin, got_rev_arg = 0, revarg_opt; + int i, flags, left, seen_dashdash, got_rev_arg = 0, revarg_opt; struct argv_array prune_data = ARGV_ARRAY_INIT; const char *submodule = NULL; @@ -2345,7 +2345,6 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s revarg_opt = opt ? opt->revarg_opt : 0; if (seen_dashdash) revarg_opt |= REVARG_CANNOT_BE_FILENAME; - read_from_stdin = 0; for (left = i = 1; i < argc; i++) { const char *arg = argv[i]; if (*arg == '-') { @@ -2364,7 +2363,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s argv[left++] = arg; continue; } - if (read_from_stdin++) + if (revs->read_from_stdin++) die("--stdin given twice?"); read_revisions_from_stdin(revs, &prune_data); continue; diff --git a/revision.h b/revision.h index c599c34da9..5f020b4616 100644 --- a/revision.h +++ b/revision.h @@ -81,6 +81,11 @@ struct rev_info { */ int rev_input_given; + /* + * Whether we read from stdin due to the --stdin option. + */ + int read_from_stdin; + /* topo-sort */ enum rev_sort_order sort_order; diff --git a/t/t6018-rev-list-glob.sh b/t/t6018-rev-list-glob.sh index 0bf10d0686..db8a7834d8 100755 --- a/t/t6018-rev-list-glob.sh +++ b/t/t6018-rev-list-glob.sh @@ -255,7 +255,7 @@ test_expect_success 'rev-list accumulates multiple --exclude' ' compare rev-list "--exclude=refs/remotes/* --exclude=refs/tags/* --all" --branches ' -test_expect_failure 'rev-list should succeed with empty output on empty stdin' ' +test_expect_success 'rev-list should succeed with empty output on empty stdin' ' git rev-list --stdin </dev/null >actual && test_must_be_empty actual ' |