From 348aa94ee0d2ce645bd7504ba8e21090fb9c5797 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 7 Nov 2026 13:05:44 -1000 Subject: Name the followed path in the diffstat header With follow set the diff runs over the whole commit and show_filepair applies the path, so the header read (limited to '') whether or not a path was given. --- tests/t0107-diff.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests') diff --git a/tests/t0107-diff.sh b/tests/t0107-diff.sh index 1f12220..861ca44 100755 --- a/tests/t0107-diff.sh +++ b/tests/t0107-diff.sh @@ -170,6 +170,28 @@ test_expect_success 'so does the commit page limited to the new name' ' ! grep "a/file-1 b/file-1" tmp ' +# Following a file diffs the whole commit and keeps the pairs on that path, +# and the header still names the path rather than the empty limit the walk +# runs under. +test_expect_success 'a followed file is diffed as the rename alone' ' + cgitrc_repo followrc moved enable-follow-links=1 && + cgit_ok followrc "url=moved/diff/new.txt&follow=1" >tmp && + grep "diff --git a/old.txt b/new.txt" tmp && + grep "Diffstat (limited to .new.txt.)" tmp && + grep "
1 file changed, 0 insertions, 0 deletions
" tmp && + ! grep "a/file-1 b/file-1" tmp && + cgit_ok followrc "url=moved/commit/new.txt&follow=1" >tmp && + grep "diff --git a/old.txt b/new.txt" tmp && + grep "Diffstat (limited to .new.txt.)" tmp && + ! grep "a/file-1 b/file-1" tmp +' + +test_expect_success 'following with no path limits nothing' ' + cgit_ok followrc "url=moved/commit/&follow=1" >tmp && + grep "diff --git a/file-1 b/file-1" tmp && + grep "
]*>Diffstat
" tmp +' + test_expect_success 'a file added outright still shows as new' ' added=$(git -C repos/moved rev-parse HEAD~1) && cgit_ok movedrc "url=moved/diff/old.txt&id=$added" >tmp && -- cgit 2.12.1