Skip to content
  • Jeff King's avatar
    rev-list: make empty --stdin not an error · a12cbe23
    Jeff King authored and Junio C Hamano's avatar Junio C Hamano committed
    When we originally did the series that contains 7ba82629
    (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: default avatarJunio C Hamano <gitster@pobox.com>
    Signed-off-by: default avatarJeff King <peff@peff.net>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    a12cbe23