diff options
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
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.
Diffstat (limited to '')
-rwxr-xr-xtests/t0104-tree.sh26
1 file changed, 26 insertions, 0 deletions
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</a>" 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 " -> <a class=.ls-blob. href=./links/tree/target.txt.>target.txt</a>" tmp &&
+ grep " -> /etc/passwd</td>" tmp &&
+ ! grep "href=./links/tree/etc/passwd" tmp
+'
+
test_done