From 62786f9a509a06ac031c066837d7a2285469677b Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 8 Aug 2026 12:49:54 -1000 Subject: Emit generated runs in batches, not a write each --- tests/t0106-diff.sh | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'tests') diff --git a/tests/t0106-diff.sh b/tests/t0106-diff.sh index 3e0d15c..4074276 100755 --- a/tests/t0106-diff.sh +++ b/tests/t0106-diff.sh @@ -51,4 +51,57 @@ test_expect_success 'ssdiff still numbers a hunk that carries a length' ' grep "#n1.>1" tmp ' +# --- Intra-line highlighting across many changed pairs ---------------------- +# The character-level highlight reuses one table across every changed pair. +# Lines shrink down the file so a short comparison always follows a longer one, +# which is where a stale cell would show up as misplaced del and add spans. +test_expect_success 'set up a repo with shrinking changed lines' ' + mkrepo repos/lcs 1 && + ( + cd repos/lcs && + awk "BEGIN{for(n=120;n>0;n-=3){s=\"\"; + for(i=0;ilines.txt && + git add lines.txt && + git commit -m "add lines.txt" && + awk "BEGIN{for(n=120;n>0;n-=3){s=\"\"; + for(i=0;ilines.txt && + git commit -am "change every line" + ) && + { + echo "virtual-root=/" && + echo "cache-size=0" && + echo "repo.url=lcs" && + echo "repo.path=$PWD/repos/lcs/.git" + } >lcsrc +' + +test_expect_success 'every changed pair gets both a del and an add span' ' + CGIT_CONFIG="$PWD/lcsrc" QUERY_STRING="url=lcs/diff/&dt=1" cgit >tmp && + dels=$(grep -o "" tmp | wc -l) && + adds=$(grep -o "" tmp | wc -l) && + test "$dels" -gt 0 && + test "$dels" -eq "$adds" +' + +test_expect_success 'stripping the highlight leaves every line intact' ' + sed -e "s/<[^>]*>//g" tmp >plain.out && + git -C repos/lcs show HEAD~1:lines.txt >old.txt && + git -C repos/lcs show HEAD:lines.txt >new.txt && + while read -r line + do + grep -qF "$line" plain.out || { + echo "missing old line: $line" + return 1 + } + done