Skip to content

Fix config discovery under Native AOT (GitBuf marshalling) - #2188

Open
kzu wants to merge 1 commit into
libgit2:masterfrom
kzu:config-aot
Open

Fix config discovery under Native AOT (GitBuf marshalling)#2188
kzu wants to merge 1 commit into
libgit2:masterfrom
kzu:config-aot

Conversation

@kzu

@kzu kzu commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Native AOT fails to load global/system git config because sequential-layout class GitBuf marshalling does not write ptr/size back to managed code after git_config_find_*.
  • That makes Configuration.BuildSignature return null when user.name / user.email are only in global config (including via include.path).
  • Introduce blittable GitBufNative and use ref P/Invoke for path-find APIs and ConvertPath, so config discovery matches CoreCLR/dotnet run behavior.

Root cause (brief)

Under Native AOT, class-based sequential marshalling is effectively [In]-only. git_config_find_global can return success while managed GitBuf.ptr stays zero, so discovery returns no path and only local repo config is loaded.

Test plan

  • Build LibGit2Sharp for all TFMs
  • AOT publish of a small app using repo.Config.BuildSignature: HasConfig(Global) / HasConfig(System) true, signature non-null when identity is in global config
  • CoreCLR / dotnet run path still resolves global config and builds signature
  • CI on this PR

Fixes #2187

Under Native AOT, sequential-layout class marshalling for GitBuf is
effectively [In]-only, so git_config_find_* succeeds but managed ptr
stays zero and global/system config never loads. BuildSignature then
returns null when user.name/email live outside local repo config.

Use a blittable GitBufNative struct with ref P/Invoke for path-find
APIs and ConvertPath so config discovery works in AOT publishes.

Fixes libgit2#2187
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant