From 0726d18078bab9e054ed417997b5f4db48d6ffdd Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 17 Oct 2026 12:53:14 -1000 Subject: Show the root commit in a followed log A followed log diffs each commit against its parent to learn whether the file changed there, and a root commit was skipped rather than diffed against the empty tree, so a file created in the first commit never showed that commit. --- tests/t0103-log.sh | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'tests') diff --git a/tests/t0103-log.sh b/tests/t0103-log.sh index 16fabda..08f9ddd 100755 --- a/tests/t0103-log.sh +++ b/tests/t0103-log.sh @@ -45,4 +45,42 @@ test_expect_success 'no links with space in path' '! grep "href=./with space/" t test_expect_success 'no links with space in arg' '! grep "q=commit 1" tmp' test_expect_success 'commit 2 is not visible' '! grep "commit 2" tmp' +# Following a file diffs each commit for the name the file had there, so the +# root commit that created it has to be diffed too. +test_expect_success 'set up a renamed file to follow' ' + test_create_repo repos/fol && + ( + cd repos/fol && + echo 1 >a.txt && + git add a.txt && + git commit -m "create a" && + for i in 2 3 4 + do + echo $i >>a.txt && + git commit -am "edit a $i" || return 1 + done && + git mv a.txt b.txt && + git commit -m "rename to b" && + for i in 6 7 8 + do + echo $i >>b.txt && + git commit -am "edit b $i" || return 1 + done + ) && + { + echo "virtual-root=/" && + echo "cache-size=0" && + echo "enable-follow-links=1" && + echo "max-commit-count=3" && + echo "repo.url=fol" && + echo "repo.path=$PWD/repos/fol/.git" + } >folrc +' + +test_expect_success 'a followed log reaches the root commit' ' + CGIT_CONFIG="$PWD/folrc" QUERY_STRING="url=fol/log/b.txt&follow=1&ofs=6" cgit >tmp && + grep ">edit a 2<" tmp && + grep ">create a<" tmp +' + test_done -- cgit