]> git.ipfire.org Git - thirdparty/git.git/commit - sha1_name.c
get_sha1: propagate flags to child functions
authorJeff King <peff@peff.net>
Mon, 26 Sep 2016 11:59:41 +0000 (07:59 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 26 Sep 2016 18:46:30 +0000 (11:46 -0700)
commit8a10fea49b1f95daeea445072a60139590b216cf
tree6af8d5fb5afc4a9e0bda1e6f65de4663f6311b86
parent7243ffdd78d56738e568abb544eba00e8079f329
get_sha1: propagate flags to child functions

The get_sha1() function is actually implementation by many
sub-functions, but we do not always pass our flags around to
all of those functions. As a result, we may forget that our
caller asked us to resolve with GET_SHA1_QUIETLY and output
messages. The two triggerable cases are:

  1. Resolving treeish:path will resolve the "treeish"
     portion using GET_SHA1_TREEISH, dropping all other
     flags.

  2. The peel_onion() function did not take flags at all
     but recurses to get_sha1_1(), which does.

The solution for both is to bitwise-OR their new flags with
the existing ones (after dropping any mutually exclusive
disambiguation flags).

This bug can trigger with "git rev-parse --quiet", which
asks for quiet resolution. But it can also happen in a more
vanilla code path when we do a follow-up ONLY_TO_DIE
invocation of get_sha1(), and that's what the tests check.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sha1_name.c
t/t1512-rev-parse-disambiguation.sh