summaryrefslogtreecommitdiff
path: root/builtin/rev-list.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2018-08-22 21:37:23 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-08-22 21:44:50 (GMT)
commita12cbe23ef765e89ba5b0872f6330a693ea391d2 (patch)
tree0d0dbb7fdd6f3db7301c3e685fdcea0a329b3283 /builtin/rev-list.c
parentb89b4a660cecc5555d48c9603b799f7393f23505 (diff)
downloadgit-a12cbe23ef765e89ba5b0872f6330a693ea391d2.zip
git-a12cbe23ef765e89ba5b0872f6330a693ea391d2.tar.gz
git-a12cbe23ef765e89ba5b0872f6330a693ea391d2.tar.bz2
rev-list: make empty --stdin not an error
When we originally did the series that contains 7ba826290a (revision: add rev_input_given flag, 2017-08-02) the intent was that "git rev-list --stdin </dev/null" would similarly become a successful noop. However, an attempt at the time to do that did not work[1]. The problem is that rev_input_given serves two roles: - it tells rev-list.c that it should not error out - it tells revision.c that it should not have the "default" ref kick (e.g., "HEAD" in "git log") We want to trigger the former, but not the latter. This is technically possible with a single flag, if we set the flag only after revision.c's revs->def check. But this introduces a rather subtle ordering dependency. Instead, let's keep two flags: one to denote when we got actual input (which triggers both roles) and one for when we read stdin (which triggers only the first). This does mean a caller interested in the first role has to check both flags, but there's only one such caller. And any future callers might want to make the distinction anyway (e.g., if they care less about erroring out, and more about whether revision.c soaked up our stdin). In fact, we already keep such a flag internally in revision.c for this purpose, so this is really just exposing that to the caller (and the old function-local flag can go away in favor of our new one). [1] https://public-inbox.org/git/20170802223416.gwiezhbuxbdmbjzx@sigill.intra.peff.net/ Helped-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/rev-list.c')
-rw-r--r--builtin/rev-list.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index 6fcb0ff..475cfcf 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);