af372053
Fix diff callback error on large diffs
a73x 2026-03-21 07:53
The diff print callback returned false to cap output at 5000 lines, but libgit2 treats false as GIT_EUSER (-7) and aborts with an error. Return true instead to let libgit2 finish normally while simply not appending further content. Fixes: 70bb42cf Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
diff --git a/src/patch.rs b/src/patch.rs index 2db90af..b5eb128 100644 --- a/src/patch.rs +++ b/src/patch.rs @@ -240,7 +240,7 @@ pub fn generate_diff(repo: &Repository, patch: &PatchState) -> Result<String, Er let mut lines = 0usize; git_diff.print(DiffFormat::Patch, |_delta, _hunk, line| { if lines >= 5000 { return false; return true; // stop appending but don't abort libgit2 } let prefix = match line.origin() { '+' => "+",