From 8273c8b176e9fc2cb2898b7ee76af2a8558db4ff Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Wed, 12 Aug 2026 19:26:32 -1000 Subject: Tidy the test comments and shell portability --- tests/t0106-diff.sh | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'tests/t0106-diff.sh') diff --git a/tests/t0106-diff.sh b/tests/t0106-diff.sh index 4074276..175f609 100755 --- a/tests/t0106-diff.sh +++ b/tests/t0106-diff.sh @@ -1,5 +1,12 @@ #!/bin/sh +# The diff page renders the change a commit made, either as unified text or, +# when dt=1 asks for it, as a side by side table. The first checks read the +# markup for one added file in the repository the shared setup builds. The +# rest build small repositories of their own, shaped so the side by side +# renderer meets the two cases it used to get wrong, a hunk covering a single +# line and a file where every line changed. + test_description='Check content on diff page' . ./setup.sh @@ -16,10 +23,10 @@ test_expect_success 'find added line' ' grep "
+5
" tmp ' -# --- Side-by-side line numbers for a hunk that covers a single line --------- -# git writes the length only when a hunk spans more than one line, so a header -# reads "@@ -1 +1 @@". Requiring a comma after the number left those hunks -# numbered from zero, which dropped the line-number link entirely. +# git writes a hunk length only when the hunk spans more than one line, so the +# header for a single line reads "@@ -1 +1 @@" with no comma in it. Requiring +# that comma left those hunks numbered from zero, which dropped the line +# number link altogether. test_expect_success 'set up a repo with single-line hunks' ' mkrepo repos/hunk1 1 && ( @@ -51,10 +58,11 @@ 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. +# The character level highlight reuses one table across every changed pair, so +# these lines get shorter as the file goes on and each comparison is smaller +# than the one before it. That is where a cell left over from the previous +# pair shows itself, as a del or an add span sitting over the wrong +# characters. test_expect_success 'set up a repo with shrinking changed lines' ' mkrepo repos/lcs 1 && ( @@ -78,10 +86,10 @@ test_expect_success 'set up a repo with shrinking changed lines' ' 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" + deletions=$(grep -o "" tmp | wc -l) && + additions=$(grep -o "" tmp | wc -l) && + test "$deletions" -gt 0 && + test "$deletions" -eq "$additions" ' test_expect_success 'stripping the highlight leaves every line intact' ' -- cgit v2.8.0