From d3ad70a618ee0e70ade487841a9b9da4c13f5a20 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 7 Nov 2026 13:21:30 -1000 Subject: Check which commits max-patch-count keeps Only the number of patches was counted, so keeping the oldest two of a range would have passed. The default of 50 and the 0 that lifts the bound had no test. --- tests/t0109-patch.sh | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/tests/t0109-patch.sh b/tests/t0109-patch.sh index 88e94ae..f87f145 100755 --- a/tests/t0109-patch.sh +++ b/tests/t0109-patch.sh @@ -53,15 +53,27 @@ test_expect_success 'compare the range with git-format-patch(1)' ' test_cmp expect actual ' -test_expect_success 'max-patch-count bounds a patch range' ' - { - echo "cache-size=0" && - echo "max-patch-count=2" && - echo "repo.url=foo" && - echo "repo.path=$PWD/repos/foo/.git" - } >patchcountrc && - cgit_rc patchcountrc "url=foo/patch&id=$id&id2=$root" >tmp && - test $(grep -c "^From " tmp) -eq 2 +# git cuts the walk short before it reverses it, so the newest commits are +# the ones kept. +test_expect_success 'max-patch-count keeps the newest commits of a range' ' + root=$(git -C repos/foo rev-list --max-parents=0 HEAD) && + cgitrc_repo patchcountrc foo max-patch-count=2 && + cgit_ok patchcountrc "url=foo/patch&id2=$root" >tmp && + grep "^Subject: " tmp >actual && + test_write_lines "Subject: commit 4" "Subject: commit 5" >expect && + test_cmp expect actual +' + +# The range below holds one commit more than the default bound. +test_expect_success 'max-patch-count defaults to 50 and 0 lifts it' ' + mkrepo repos/many 52 >/dev/null && + root=$(git -C repos/many rev-list --max-parents=0 HEAD) && + cgitrc_repo manyrc many && + cgit_ok manyrc "url=many/patch&id2=$root" >tmp && + test $(grep -c "^From [0-9a-f]* Mon Sep 17 00:00:00 2001$" tmp) -eq 50 && + cgitrc_repo manyrc many max-patch-count=0 && + cgit_ok manyrc "url=many/patch&id2=$root" >tmp && + test $(grep -c "^From [0-9a-f]* Mon Sep 17 00:00:00 2001$" tmp) -eq 51 ' test_expect_success 'the signature names the version when asked to' ' -- cgit 2.12.1