Skip to content

Commit ed1ca60

Browse files
committed
peel_onion: disambiguate to favor tree-ish when we know we want a tree-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 <[email protected]>
1 parent 3322ad4 commit ed1ca60

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

sha1_name.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,8 @@ static int peel_onion(const char *name, int len, unsigned char *sha1)
654654

655655
if (expected_type == OBJ_COMMIT)
656656
lookup_flags = GET_SHA1_COMMITTISH;
657+
else if (expected_type == OBJ_TREE)
658+
lookup_flags = GET_SHA1_TREEISH;
657659

658660
if (get_sha1_1(name, sp - name - 2, outer, lookup_flags))
659661
return -1;

0 commit comments

Comments
 (0)