diff options
context:
space:
mode:
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Cap diff blobs by `max-blob-size`
The diff family inflated a blob of any size just to render it. A file over the limit is reported as binary instead.
Diffstat (limited to '')
-rwxr-xr-xtests/t0201-limits.sh26
1 file changed, 26 insertions, 0 deletions
diff --git a/tests/t0201-limits.sh b/tests/t0201-limits.sh
index 1ab3ce6..5f04952 100755
--- a/tests/t0201-limits.sh
+++ b/tests/t0201-limits.sh
@@ -100,6 +100,32 @@ test_expect_success 'the single-file page is not limited by max-diff-files' '
grep "class=.hunk." tmp
'
+# --- max-blob-size also bounds the diff path --------------------------------
+# The diff family must not inflate a blob larger than max-blob-size just to
+# render it. Such a file is reported as binary instead of inlined.
+test_expect_success 'a diff of an oversized blob is not inlined' '
+ mkrepo repos/blobdiff 1 &&
+ (
+ cd repos/blobdiff &&
+ awk "BEGIN{for(i=0;i<400;i++)print \"aaaaaaaa\"}" >big.txt &&
+ git add -A &&
+ git commit -m add &&
+ awk "BEGIN{for(i=0;i<401;i++)print \"aaaaaaaa\"}" >big.txt &&
+ git commit -am change
+ ) &&
+ {
+ echo "virtual-root=/" &&
+ echo "cache-size=0" &&
+ echo "max-blob-size=1" &&
+ echo "repo.url=blobdiff" &&
+ echo "repo.path=$PWD/repos/blobdiff/.git"
+ } >blobdiffrc &&
+ sha=$(git -C repos/blobdiff rev-parse HEAD) &&
+ CGIT_CONFIG="$PWD/blobdiffrc" QUERY_STRING="url=blobdiff/commit/&id=$sha" cgit >tmp &&
+ grep "Binary files differ" tmp &&
+ ! grep "aaaaaaaa" tmp
+'
+
# --- The shipped highlight filter degrades to escaped passthrough -----------
test_expect_success LUA 'highlight filter passes text through without scintillua' '
{