Web lists-archives.com

Incorrect tree shown with ls-tree ref^{type}:{{folder}}

Suppose I have a repository that has the following files:


The following works fine:

$ git ls-tree master^{tree}
040000 tree 9284ac5fef7ad99a2bd508a8c89bde8bd1a88e9f    foo

$ git ls-tree master^{tree}:foo
040000 tree 69497de4d9a72713f87df8280a147e0a597c4055    bar
040000 tree b2abdac384f111c1a8a518e05b963a3bb2541659    {{curly}}

$ git ls-tree master^{tree}:foo/bar
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391    test1.txt

$ git ls-tree master:foo/{{curly}}
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391    test2.txt

However, the following returns the root tree instead of the tree
belonging to {{curly}}:

$ git ls-tree master^{tree}:foo/{{curly}}
040000 tree 9284ac5fef7ad99a2bd508a8c89bde8bd1a88e9f    foo

I believe the problem is on this line in sha1-name.c:peel_onion()

if (len < 4 || name[len-1] != '}')

Since name is "master^{tree}:foo/{{curly}}", peel_onion() returns
early, thinking it is done.

I can append a '/' to force peel_onion() to work, but is that the
right thing to do here? Should this condition handle the
"ref^{type}:filename" case properly?