Skip to content

Update libgit2 overlay to v1.9.7 and fix safe.directory case matching on Windows - #2095

Draft
tyrielv wants to merge 1 commit into
microsoft:vnextfrom
tyrielv:tyrielv/libgit2-safe-directory-icase
Draft

Update libgit2 overlay to v1.9.7 and fix safe.directory case matching on Windows#2095
tyrielv wants to merge 1 commit into
microsoft:vnextfrom
tyrielv:tyrielv/libgit2-safe-directory-icase

Conversation

@tyrielv

@tyrielv tyrielv commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Update the pinned libgit2 vcpkg overlay from v1.9.4 to v1.9.7 (the latest 1.9.x release) and add a patch that makes safe.directory allowlist matching case-insensitive on Windows.

Problem

On Windows, Git canonicalizes both the repository path and each safe.directory allowlist entry to their on-disk form before it compares them, so the match is effectively case-insensitive over the whole path, including the drive letter. libgit2 compared the paths with a case-sensitive strcmp, so an entry like c:/repo did not match a repository recorded as C:/repo. A drive-letter case mismatch is the common case. The repository then failed to open with a spurious GIT_EOWNER ownership error.

Fix

The patch switches the comparison to STRCMP_CASESELECT gated on GIT_WIN32. POSIX filesystems stay case-sensitive. It carries the fix from libgit2 issue #7037, rebased onto v1.9.7. The upstream commit targets libgit2 main, whose validate_ownership_cb has an extra %(prefix) handling branch that v1.9.7 lacks, so the overlay carries only the single-comparison hunk. The upstream Windows-only tests are omitted because the overlay builds with BUILD_TESTS=OFF.

Changes

  • overlays/libgit2/safe-directory-icase.diff — new patch (issue #7037)
  • overlays/libgit2/portfile.cmake — add the patch to PATCHES; bump SHA512
  • overlays/libgit2/vcpkg.jsonversion-semver 1.9.4 → 1.9.7
  • overlays/libgit2/README.md — document the patch and the version bump

Verification

  • All three overlay patches apply cleanly to the v1.9.7 source.
  • A full vcpkg build of libgit2 v1.9.7 (x64-windows-dynamic) with the overlay compiles repository.c and produces git2.dll.

Bump the pinned libgit2 vcpkg overlay from v1.9.4 to v1.9.7, the latest
1.9.x release, and add a patch that makes safe.directory allowlist
matching case-insensitive on Windows.

On Windows, Git canonicalizes both the repository path and each
safe.directory allowlist entry to their on-disk form before comparing
them, so the match is effectively case-insensitive over the whole path,
including the drive letter. libgit2 compared the paths with a
case-sensitive strcmp, so an entry like c:/repo did not match a
repository recorded as C:/repo (a drive-letter case mismatch is the
common case), and the repository failed to open with a spurious
GIT_EOWNER ownership error.

The patch switches the comparison to STRCMP_CASESELECT gated on
GIT_WIN32; POSIX filesystems stay case-sensitive. It carries the fix
from libgit2 issue 7037 (fork branch tyrielv/safe-directory-drive-case,
commit 6074349), rebased onto v1.9.7. The upstream commit targets
libgit2 main, whose validate_ownership_cb has an extra %(prefix)
handling branch that v1.9.7 lacks, so the overlay carries only the
single-comparison hunk. The upstream Windows-only tests are omitted
because the overlay builds with BUILD_TESTS=OFF.

Verified: all three overlay patches apply cleanly to the v1.9.7 source,
and a full vcpkg build of libgit2 v1.9.7 (x64-windows-dynamic) with the
overlay compiles repository.c and produces git2.dll.

Assisted-by: Claude Opus 4.8
Signed-off-by: Tyrie Vella <tyrielv@gmail.com>
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