Skip to content

refactor: drop the patched libgit2-sys and quote rename names before parsing - #2

Merged
backnotprop merged 1 commit into
mainfrom
chore/drop-libgit2-patch
Oct 27, 2026
Merged

backnotprop merged 1 commit into
mainfrom
chore/drop-libgit2-patch

Conversation

@backnotprop

Copy link
Copy Markdown
Contributor

Removes vendor/libgit2-sys and its [patch.crates-io] entry. The build now uses the published libgit2-sys 0.18.8+1.9.7 (checksum matches the original crate recorded in the old patch note).

What replaces the patch

Stock libgit2 stops an unquoted rename from/to or copy from/to name at the first whitespace byte. src/model/rename_names.rs rewrites only those header names, inside a diff --git extended header, into Git's C-quoted form, which libgit2 decodes exactly. Hunk lines are never touched, and parser content offsets are mapped back to the supplied bytes, so line numbers, source offsets and source context are unchanged (the existing Parser source offset does not match the supplied patch check still guards every line).

Names libgit2 already reads correctly, quoted names, and empty names are left as written; malformed quoted names remain errors. Patches without a rename /copy line skip the pass after a memmem check.

The other half of the old patch, refusing a system libgit2, moves to a crate build.rs that rejects a nonzero LIBGIT2_NO_VENDOR. A unit test asserts git2::Version::get().vendored().

Also cargo update -p clipboard-win (5.4.1 is yanked → 5.4.3). The only other lockfile change is libgit2-sys gaining its registry source and checksum.

Checks

  • cargo fmt --check; clippy -D warnings for default, --all-features, and --lib --no-default-features.
  • cargo test --release --locked -- --test-threads=1: 255 passed, 0 failed, 10 ignored; embedded host contract: 6 passed.
  • New unit tests: spaces, leading/trailing spaces, tabs, unicode, backslashes and quotes, control bytes, already-quoted names, CRLF, diff --git header consistency, equivalence with Git's quoted spelling, multi-file offset mapping. Two of them fail with the rewrite disabled.
  • inspect JSON is byte-identical to the main build for all five DiffsHub corpus patches, the repository fixtures, and a linux v6-v7 variant where all 7,480 rename/copy names gained interior and trailing spaces.
  • tools/parse_baseline.py, 3 runs each, main vs this branch: no time or peak-RSS regression (linux v6-v7 median 5.72 s / 385 MiB vs 5.38 s / 382 MiB).

…parsing

Stock libgit2 cuts unquoted rename and copy names at whitespace. Rewrite
those header names into Git's quoted form, which libgit2 decodes exactly,
and map parser offsets back to the supplied patch. A build script keeps
rejecting LIBGIT2_NO_VENDOR so a system libgit2 is never linked.

Also update the yanked clipboard-win 5.4.1 to 5.4.3.
@backnotprop
backnotprop merged commit 4c179e8 into main Oct 27, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant