From b94bde1b3cb7725e41eb61efbac891fafa9c90d9 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 31 Oct 2026 13:15:47 -0700 Subject: Tidy up after a directory chain however it ends A row whose first entry is itself a directory leaked that entry's name. A level git could not read as a tree returned early instead, which also left the row's log, stats and plain links on the deeper path. --- tests/t0104-tree.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'tests') diff --git a/tests/t0104-tree.sh b/tests/t0104-tree.sh index 41134a4..0ed98a6 100755 --- a/tests/t0104-tree.sh +++ b/tests/t0104-tree.sh @@ -198,6 +198,33 @@ test_expect_success 'a long directory chain ends on a link' ' ! grep " / " tmp ' +# Git holds one object per id, as the type it was first looked up as, so a +# folder the commit also names as its parent cannot be read as a tree and the +# chain stops on it. The rest of the row still belongs to the first folder. +test_expect_success 'a broken chain keeps the row links on the first folder' ' + test_create_repo repos/cut && + ( + cd repos/cut && + mkdir -p a/b && + echo x >a/b/file && + git add a && + git commit -m base && + odd=$(printf "tree %s\\nparent %s\\nauthor A 1700000000 +0000\\ncommitter A 1700000000 +0000\\n\\nodd\\n" \ + $(git rev-parse HEAD^{tree}) $(git rev-parse HEAD:a/b) | + git hash-object -t commit -w --stdin --literally) && + git update-ref refs/heads/odd $odd + ) && + { + echo "virtual-root=/" && + echo "cache-size=0" && + echo "repo.url=cut" && + echo "repo.path=$PWD/repos/cut/.git" + } >cutrc && + CGIT_CONFIG="$PWD/cutrc" QUERY_STRING="url=cut/tree/&h=odd" cgit >tmp && + grep ">b" tmp && + grep "href=./cut/log/a?h=odd.>log" tmp +' + test_expect_success 'a binary file in the tree shows as a hex dump' ' test_create_repo repos/bin && ( -- cgit 2.11.1