Diff options
Diffstat (limited to 'tests/t0107-diff.sh')
| -rwxr-xr-x | tests/t0107-diff.sh | 35 |
1 file changed, 35 insertions, 0 deletions
diff --git a/tests/t0107-diff.sh b/tests/t0107-diff.sh index e173d00..d03ecd2 100755 --- a/tests/t0107-diff.sh +++ b/tests/t0107-diff.sh @@ -104,4 +104,39 @@ test_expect_success 'stripping the highlight leaves every line intact' ' done <lines ' +# The diffstat links a renamed file by its new name, and so does the log of +# that file, but the old name lies outside a diff limited to the new one. +test_expect_success 'set up a renamed file' ' + mkrepo repos/moved 1 && + ( + cd repos/moved && + test_seq 1 10 >old.txt && + git add old.txt && + git commit -m "add old.txt" && + git mv old.txt new.txt && + git commit -m "rename old.txt" + ) && + cgitrc_repo movedrc moved +' + +test_expect_success 'the diff of a renamed file shows the rename' ' + cgit_rc movedrc "url=moved/diff/new.txt" >tmp && + grep "diff --git a/old.txt b/new.txt" tmp && + grep "</a> (renamed from old.txt)</td>" tmp && + ! grep "new file mode" tmp +' + +test_expect_success 'so does the commit page limited to the new name' ' + cgit_rc movedrc "url=moved/commit/new.txt" >tmp && + grep "diff --git a/old.txt b/new.txt" tmp && + ! grep "new file mode" tmp +' + +test_expect_success 'a file added outright still shows as new' ' + added=$(git -C repos/moved rev-parse HEAD~1) && + cgit_rc movedrc "url=moved/diff/old.txt&id=$added" >tmp && + grep "new file mode 100644" tmp && + grep "<div class=.add.>+10</div>" tmp +' + test_done |
