httpd: Bound the diff in commit and diff responses

Commits with large or many files, like a vendored driver with 3,790
files, OOM-killed httpd at its 2 GiB limit. radicle-surf diffs every
file twice and its rename detection loads whole blobs, so its output
can't be bounded, and httpd now builds the diff itself.

Files over 1 MiB or 50,000 lines, or past the per-response budgets,
aren't diffed and come back as binary with `"tooLarge": true`. Files
after the first 3,000 are left out. The diff is then `"truncated"` and
takes its stats from `git diff --numstat`. This also fixes files shrunk
from over the limit showing up as empty.

`git2` becomes a direct dependency, at the version `radicle` already
uses, for the diff types `radicle::git::raw` doesn't re-export.

Co-authored-by: Rūdolfs Ošiņš <rudolfs@osins.org>
This commit is contained in:
Yorgos Saslis
2026-12-01 16:30:56 +01:00
committed by Rūdolfs Ošiņš
co-authored by Rūdolfs Ošiņš
parent 693ce8661d
commit 9dd13264e0
5 changed files with 539 additions and 9 deletions
+9
View File
@@ -37,6 +37,15 @@ Explorer supports httpd 0.28.0 and newer, set by `minimumSupportedVersion` in
- Changed in place: `files` in the commit and diff responses leaves out blobs
over 512 KiB, and blobs once the response holds 8 MiB of them. Both sides of a
file are left out together. Older clients already handle a missing blob.
- Added: `tooLarge` on a file's `binary` diff, for files httpd did not diff
because of their size, and `truncated` on the diff when any file was not
diffed or was left out. Both are optional in the client.
- Changed in place: text files over the diff limits come back as `binary`, and
files after the first 3,000 are left out. A truncated diff takes its stats
from `git diff --numstat`, which counts every file. Older clients show these
files as binary.
- Changed in place: `git diff --numstat`, also behind `/diff/:base/:oid/stats`,
counts files over 1 MiB as binary, with no lines.
- Read by: client.
## 0.31.0