diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Hold patch and rawdiff to max-blob-size
Both pages hand the diff to git, whose own limit on an inlined blob is
512 MB, so a commit adding a blob the other views refuse was inflated
and diffed in full. The cap is passed through to git, which shows such a
blob as binary.
| -rw-r--r-- | source/ui-diff.c | 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -rw-r--r-- | source/ui-patch.c | 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -rwxr-xr-x | tests/t0204-limits.sh | 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
3 files changed, 26 insertions, 0 deletions
diff --git a/source/ui-diff.c b/source/ui-diff.c index f133a9c..2da44c4 100644 --- a/source/ui-diff.c +++ b/source/ui-diff.c @@ -540,6 +540,10 @@ static void print_raw_patch(const struct object_id *old_tree_oid, const struct o { struct diff_options diffopt; + // As on the patch page, a blob past max-blob-size is shown as binary + // rather than inflated. + if (ctx.cfg.max_blob_size) + repo_settings_set_big_file_threshold(the_repository, (unsigned long)ctx.cfg.max_blob_size * 1024); repo_diff_setup(the_repository, &diffopt); diffopt.output_format = DIFF_FORMAT_PATCH; diffopt.flags.recursive = 1; diff --git a/source/ui-patch.c b/source/ui-patch.c index 7191542..525e660 100644 --- a/source/ui-patch.c +++ b/source/ui-patch.c @@ -97,6 +97,10 @@ void cgit_print_patch(const char *new_rev, const char *old_rev, const char *pref "From: %an%nDate: %aD%n%w(78,0,1)Subject: %s%n%n%w(0)%b"; } + // Git inlines a blob up to its own big-file threshold, far past what + // any other view inflates, so max-blob-size is applied through it. + if (ctx.cfg.max_blob_size) + repo_settings_set_big_file_threshold(the_repository, (unsigned long)ctx.cfg.max_blob_size * 1024); repo_init_revisions(the_repository, &rev, NULL); rev.abbrev = DEFAULT_ABBREV; rev.verbose_header = 1; diff --git a/tests/t0204-limits.sh b/tests/t0204-limits.sh index b1c797a..2d33368 100755 --- a/tests/t0204-limits.sh +++ b/tests/t0204-limits.sh @@ -214,4 +214,22 @@ test_expect_success LUA 'highlight filter passes text through without scintillua grep "int y;" tmp ' +# The patch and rawdiff pages hand the work to git, whose own limit on an +# inlined blob is far past max-blob-size, so the cap is passed through to it. +test_expect_success 'patch and rawdiff show an oversized blob as binary' ' + test_seq 1 2000 >repos/limits/big.txt && + git -C repos/limits add big.txt && + git -C repos/limits commit -q -m "big blob" && + { + echo "max-blob-size=1" && + cat limitrc + } >blobrc && + for p in patch rawdiff + do + CGIT_CONFIG="$PWD/blobrc" QUERY_STRING="url=limits/$p/" cgit >tmp && + grep "^Binary files" tmp && + ! grep "^+1999$" tmp || return 1 + done +' + test_done |
