summaryrefslogtreecommitdiff
path: root/revision.h
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2018-08-22 17:37:23 -0400
committerJunio C Hamano <gitster@pobox.com>2018-08-22 14:44:50 -0700
commita12cbe23ef765e89ba5b0872f6330a693ea391d2 (patch)
tree0d0dbb7fdd6f3db7301c3e685fdcea0a329b3283 /revision.h
parentb89b4a660cecc5555d48c9603b799f7393f23505 (diff)
downloadgit-a12cbe23ef765e89ba5b0872f6330a693ea391d2.tar.gz
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 'revision.h')
-rw-r--r--revision.h5
1 files changed, 5 insertions, 0 deletions
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;