From 717c9a822db8e081c2001b79d63eaa1663277b95 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 17 Oct 2026 12:53:18 -1000 Subject: Show an absolute link target as text A symlink to /etc/passwd was resolved against the tree and linked to etc/passwd inside it, a different file or none at all. --- tests/t0104-tree.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'tests/t0104-tree.sh') diff --git a/tests/t0104-tree.sh b/tests/t0104-tree.sh index 48c8406..a2ec3c2 100755 --- a/tests/t0104-tree.sh +++ b/tests/t0104-tree.sh @@ -82,4 +82,30 @@ test_expect_success 'a file row still offers blame' ' grep ">blame" tmp ' +# A link target inside the tree becomes a link, while an absolute one names a +# file on whatever machine checks the tree out, not a path in the tree. +test_expect_success 'only a link target inside the tree is linked' ' + test_create_repo repos/links && + ( + cd repos/links && + echo hi >target.txt && + git add target.txt && + rel=$(printf target.txt | git hash-object -w --stdin) && + abs=$(printf /etc/passwd | git hash-object -w --stdin) && + git update-index --add --cacheinfo 120000,$rel,rel && + git update-index --add --cacheinfo 120000,$abs,abs && + git commit -m links + ) && + { + echo "virtual-root=/" && + echo "cache-size=0" && + echo "repo.url=links" && + echo "repo.path=$PWD/repos/links/.git" + } >linksrc && + CGIT_CONFIG="$PWD/linksrc" QUERY_STRING="url=links/tree/" cgit >tmp && + grep " -> target.txt" tmp && + grep " -> /etc/passwd" tmp && + ! grep "href=./links/tree/etc/passwd" tmp +' + test_done -- cgit