deps: bump git2 to 0.21, clearing RUSTSEC-2026-0184#81
Merged
Conversation
git2 0.20.4's BlameHunk accessors build Signatures from potentially-null pointers, so reading them can dereference null (RUSTSEC-2026-0184). submod never calls blame, and the advisories step allows `unsound`, so this never failed CI — but the fix is a version bump and there is no reason to carry it. 0.21 is a breaking release. Five call sites in git2_ops.rs needed updating, all from the same API change: accessors that returned Option<&str> now return Result<&str, Error>, distinguishing "not valid UTF-8" from "absent" where the old signature collapsed both into None. Submodule::name() Option<&str> -> Result<&str, Error> Submodule::url() Option<&str> -> Result<Option<&str>, Error> ConfigEntry::name() Option<&str> -> Result<&str, Error> ConfigEntry::value() Option<&str> -> Result<&str, Error> StatusEntry::path() Option<&str> -> Result<&str, Error> Submodule::url() is the awkward one: it grew both wrappers, since a URL can be absent *and* a present URL can be invalid UTF-8. Call sites use .ok().flatten() to fold both back to Option, preserving current behaviour rather than changing how invalid UTF-8 is handled as a side effect of a dependency bump. Submodule::name() calls needed no change: Result::unwrap_or has the same shape as Option::unwrap_or, so `.unwrap_or(path)` still compiles and still means the same thing. libgit2-sys moves 0.18.3+1.9.2 -> 0.18.7+1.9.6. 569/569 tests pass. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XocU6NjgZricrRWMLyLXDn
Codecov Report❌ Patch coverage is
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to the item flagged in #79.
Why
git20.20.4'sBlameHunkaccessors constructSignatures from potentially-null pointers, so reading them can dereference null — RUSTSEC-2026-0184. submod never calls blame, and the advisories step allowsunsound, so this never failed CI. But the fix is a version bump, so there's no reason to keep carrying it.The breaking change
0.21 is a breaking release. Five call sites in
git2_ops.rsneeded updating, all from one API change — accessors that returnedOption<&str>now returnResult<&str, Error>, distinguishing "not valid UTF-8" from "absent" where the old signature collapsed both intoNone:Submodule::name()Option<&str>Result<&str, Error>Submodule::url()Option<&str>Result<Option<&str>, Error>ConfigEntry::name()Option<&str>Result<&str, Error>ConfigEntry::value()Option<&str>Result<&str, Error>StatusEntry::path()Option<&str>Result<&str, Error>Submodule::url()is the awkward one — it grew both wrappers, since a URL can be absent and a present URL can be invalid UTF-8. Call sites use.ok().flatten()to fold both back into anOption, preserving current behavior rather than changing how invalid UTF-8 is treated as a side effect of a dependency bump. That's a real (if narrow) improvement now available, but it belongs in its own change.Submodule::name()call sites needed no edit at all:Result::unwrap_orhas the same shape asOption::unwrap_or, so.unwrap_or(path)still compiles and still means the same thing.Verification
libgit2-sysmoves0.18.3+1.9.2→0.18.7+1.9.6. 569/569 tests pass,cargo fmt --checkclean,cargo deny check advisoriesclean, andRUSTSEC-2026-0184no longer appears even with theunsoundallowance removed. No new clippy warnings — the remaining ones are the pre-existing set onmain, none ingit2_ops.rs.🤖 Generated with Claude Code
https://claude.ai/code/session_01XocU6NjgZricrRWMLyLXDn