Skip to content

Commit

Permalink
peel_onion: disambiguate to favor tree-ish when we know we want a tre…
Browse files Browse the repository at this point in the history
…e-ish

The function already knows when interpreting $foo^{commit} to tell
the underlying get_sha1_1() to expect a commit-ish while evaluating
$foo.  Teach it to do the same when asked for $foo^{tree}; we are
expecting a tree-ish and $foo should be disambiguated in favor of a
tree-ish, discarding a possible ambiguous match with a blob object.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Junio C Hamano committed Mar 31, 2013
1 parent 3322ad4 commit ed1ca60
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sha1_name.c
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,8 @@ static int peel_onion(const char *name, int len, unsigned char *sha1)

if (expected_type == OBJ_COMMIT)
lookup_flags = GET_SHA1_COMMITTISH;
else if (expected_type == OBJ_TREE)
lookup_flags = GET_SHA1_TREEISH;

if (get_sha1_1(name, sp - name - 2, outer, lookup_flags))
return -1;
Expand Down

0 comments on commit ed1ca60

Please sign in to comment.