Skip to content
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 libgit2 SetOwnerValidation #2118

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions LibGit2Sharp/Core/Proxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3397,6 +3397,8 @@ private enum LibGit2Option
SetOdbLoosePriority, // GIT_OPT_SET_ODB_LOOSE_PRIORITY,
GetExtensions, // GIT_OPT_GET_EXTENSIONS,
SetExtensions, // GIT_OPT_SET_EXTENSIONS
GetOwnerValidation, // GIT_OPT_GET_OWNER_VALIDATION
SetOwnerValidation, // GIT_OPT_SET_OWNER_VALIDATION
}

/// <summary>
Expand Down Expand Up @@ -3466,6 +3468,22 @@ public static void git_libgit2_opts_set_enable_caching(bool enabled)
Ensure.ZeroResult(res);
}

/// <summary>
/// Enable or disable the libgit2 owner validation
/// </summary>
/// <param name="enabled">true to enable owner validation, false otherwise</param>
public static void git_libgit2_opts_set_owner_validation(bool enabled)
{
// libgit2 expects non-zero value for true
int res;
if (isOSXArm64)
res = NativeMethods.git_libgit2_opts_osxarm64((int)LibGit2Option.SetOwnerValidation, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, enabled ? 1 : 0);
else
res = NativeMethods.git_libgit2_opts((int)LibGit2Option.SetOwnerValidation, enabled ? 1 : 0);
Ensure.ZeroResult(res);
}


/// <summary>
/// Enable or disable the ofs_delta capabilty
/// </summary>
Expand Down
9 changes: 9 additions & 0 deletions LibGit2Sharp/GlobalSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,15 @@ public static void SetEnableCaching(bool enabled)
Proxy.git_libgit2_opts_set_enable_caching(enabled);
}

/// <summary>
/// Enable or disable the libgit2 owner validation
/// </summary>
/// <param name="enabled">true to enable the owner validation, false otherwise</param>
public static void SetOwnerValidation(bool enabled)
{
Proxy.git_libgit2_opts_set_owner_validation(enabled);
}

/// <summary>
/// Enable or disable the ofs_delta capability
/// </summary>
Expand Down