-
Notifications
You must be signed in to change notification settings - Fork 889
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose the repository directory ownership validation option #2036
Comments
Just opened a pull request for that. For now you can do it like this: public static void DisableOwnershipCheckOpts()
{
CallNativeMethod("git_libgit2_opts", 36, 0);
}
public static void CallNativeMethod(string methodName, params object[] args)
{
Assembly libGit2SharpAssembly = typeof(LibGit2Sharp.Repository).GetTypeInfo().Assembly;
Type proxyType = libGit2SharpAssembly.GetType("LibGit2Sharp.Core.NativeMethods")!;
MethodInfo methodInfo = proxyType.GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Static, new[] { typeof(int), typeof(int) })!;
methodInfo.Invoke(null, args);
} |
Thanks @kdlslyv for the pull request and the workaround. Hope your PR will be merged soon. internal static partial class GlobalSettings2
{
[LibraryImport("git2-e632535")]
private static partial int git_libgit2_opts(int option, int enabled);
public static void SetDirectoryOwnershipValidation(bool enable)
{
// https://github.com/libgit2/libgit2/blob/fc4c00b21983ddbe7a5e67e240c40fece4fea285/include/git2/common.h#L225
const int GIT_OPT_SET_OWNER_VALIDATION = 36;
// https://github.com/libgit2/libgit2/blob/fc4c00b21983ddbe7a5e67e240c40fece4fea285/include/git2/common.h#L487
int enabled = enable ? 1 : 0;
if (git_libgit2_opts(GIT_OPT_SET_OWNER_VALIDATION, enabled) < 0)
throw new Exception($"git_libgit2_opts(GIT_OPT_SET_OWNER_VALIDATION, {enabled}) failed.");
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can now disable the repository directory ownership validation by using the
GIT_OPT_SET_OWNER_VALIDATION
withgit_libgit2_opts()
: libgit2/libgit2#6266This option is not yet exposed in the C# bindings, e.g. in the
GlobalSettings
static class.Thanks.
The text was updated successfully, but these errors were encountered: