diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2026-03-30 08:54:31 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2026-03-30 16:29:19 +0000 |
| commit | 3a03cca6eb6597c19f5146c5f0d18f9230eb0fae (patch) | |
| tree | 94597b3298e34d5d31083255bee605617accaab5 /src/lib/git/utils.rs | |
| parent | f3a6ae82ccee44dc3b66a66caafe1bb39e7a46a6 (diff) | |
fix(patch): handle diff.noprefix and normalize non-standard diff paths
libgit2 respects the user's `diff.noprefix` git config when generating
patches via `git_email_create_from_commit`, producing diffs without the
standard `a/`/`b/` path prefixes. `git2::Diff::from_buffer` always
expects the standard prefix format and fails with "header filename does
not contain 1 path components" when it is absent.
Two fixes:
- In `make_patch_from_commit`: explicitly set `old_prefix("a/")` and
`new_prefix("b/")` on the diff options so ngit always generates
interoperable patches regardless of the submitter's git config.
- In `create_commit_from_patch`: normalize no-prefix diffs before
passing to `git2::Diff::from_buffer`, as a defensive measure for
patches already published by affected ngit versions or other tools.
Adds unit tests for the normalization function covering: no-op on
already-prefixed diffs, single and multi-file patches, new/deleted
files (/dev/null preservation), and end-to-end libgit2 parse
verification.
Diffstat (limited to 'src/lib/git/utils.rs')
0 files changed, 0 insertions, 0 deletions