Skip to content
  • Jeff King's avatar
    get_sha1: don't die() on bogus search strings · aac4fac1
    Jeff King authored and Junio C Hamano's avatar Junio C Hamano committed
    
    
    The get_sha1() function generally returns an error code
    rather than dying, and we sometimes speculatively call it
    with something that may be a revision or a pathspec, in
    order to see which one it might be.
    
    If it sees a bogus ":/" search string, though, it complains,
    without giving the caller the opportunity to recover. We can
    demonstrate this in t6133 by looking for ":/*.t", which
    should mean "*.t at the root of the tree", but instead dies
    because of the invalid regex (the "*" has nothing to operate
    on).
    
    We can fix this by returning an error rather than calling
    die(). Unfortunately, the tradeoff is that the error message
    is slightly worse in cases where we _do_ know we have a rev.
    E.g., running "git log ':/*.t' --" before yielded:
    
      fatal: Invalid search pattern: *.t
    
    and now we get only:
    
      fatal: bad revision ':/*.t'
    
    There's not a simple way to fix this short of passing a
    "quiet" flag all the way through the get_sha1() stack.
    
    Signed-off-by: default avatarJeff King <peff@peff.net>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    aac4fac1