git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Stan Hu <stanhu@gmail.com>
Date
Dec 20, 2018, 20:05 UTC
Message-ID
<CAMBWrQ=nWQpyp3JPkBAzmZUioUTThUC9y9=xiHCtUTvA9m2yUA@mail.gmail.com>
Suppose I have a repository that has the following files:

foo/bar/test1.txt foo/{{curly}}/test2.txt

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() (https://github.com/git/git/blob/b21ebb671bb7dea8d342225f0d66c41f4e54d5ca/sha1-name.c#L1004):

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?

Message 1 of 1 in “Incorrect tree shown with ls-tree ref^{type}:{{folder}}”
  1. Stan HuDec 20, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.