]> git.ipfire.org Git - thirdparty/git.git/commit - revision.h
rev-list: make empty --stdin not an error
authorJeff King <peff@peff.net>
Wed, 22 Aug 2018 21:37:23 +0000 (17:37 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 22 Aug 2018 21:44:50 +0000 (14:44 -0700)
commita12cbe23ef765e89ba5b0872f6330a693ea391d2
tree0d0dbb7fdd6f3db7301c3e685fdcea0a329b3283
parentb89b4a660cecc5555d48c9603b799f7393f23505
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>
builtin/rev-list.c
revision.c
revision.h
t/t6018-rev-list-glob.sh