From 6fb59b3291a63445499f81b609171db0db0d90ee Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sun, 1 Nov 2026 11:29:40 -1000 Subject: Dump only the first 64 KB of a binary file --- tests/t0104-tree.sh | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/t0104-tree.sh b/tests/t0104-tree.sh index 9d6e542..490abb3 100755 --- a/tests/t0104-tree.sh +++ b/tests/t0104-tree.sh @@ -245,7 +245,24 @@ test_expect_success 'a binary file in the tree shows as a hex dump' ' cgitrc_repo binrc bin && cgit_rc binrc "url=bin/tree/blob.bin" >tmp && grep "" tmp && - grep "" tmp && + ! grep "" tmp && + grep "
Only the first 64 KB of this file are shown. View the whole file.
" tmp ' test_done -- cgit 2.12.1
0000 00 01 02 62 69 6e" tmp + grep "0000 00 01 02 62 69 6e" tmp && + ! grep "class=.truncated." tmp +' + +# Each byte of the dump costs several bytes of markup, so a large binary is +# dumped up to its first 64 KB and links to the whole file. +test_expect_success 'a large binary is dumped only in part' ' + ( + cd repos/bin && + printf "\\000" >big.bin && + test_seq 1 20000 >>big.bin && + git add big.bin && + git commit -m "large binary" + ) && + cgit_rc binrc "url=bin/tree/big.bin" >tmp && + grep "ffe010000