Skip to content

Expose enable/disable ofs delta and strict object creation settings #1505

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

Merged
Merged
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
24 changes: 23 additions & 1 deletion LibGit2Sharp/Core/Proxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3429,7 +3429,29 @@ public static void git_libgit2_opts_set_enable_caching(bool enabled)
Ensure.ZeroResult(res);
}

#endregion
/// <summary>
/// Enable or disable the ofs_delta capabilty
/// </summary>
/// <param name="enabled">true to enable the ofs_delta capabilty, false otherwise</param>
public static void git_libgit2_opts_set_enable_ofsdelta(bool enabled)
{
// libgit2 expects non-zero value for true
var res = NativeMethods.git_libgit2_opts((int)LibGit2Option.EnableOfsDelta, enabled ? 1 : 0);
Ensure.ZeroResult(res);
}

/// <summary>
/// Enable or disable the strict_object_creation capabilty
/// </summary>
/// <param name="enabled">true to enable the strict_object_creation capabilty, false otherwise</param>
public static void git_libgit2_opts_set_enable_strictobjectcreation(bool enabled)
{
// libgit2 expects non-zero value for true
var res = NativeMethods.git_libgit2_opts((int)LibGit2Option.EnableStrictObjectCreation, enabled ? 1 : 0);
Ensure.ZeroResult(res);
}

#endregion

private static ICollection<TResult> git_foreach<T, TResult>(
Func<T, TResult> resultSelector,
Expand Down
18 changes: 18 additions & 0 deletions LibGit2Sharp/GlobalSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -338,5 +338,23 @@ public static void SetEnableCaching(bool enabled)
{
Proxy.git_libgit2_opts_set_enable_caching(enabled);
}

/// <summary>
/// Enable or disable the ofs_delta capability
/// </summary>
/// <param name="enabled">true to enable the ofs_delta capability, false otherwise</param>
public static void SetEnableOfsDelta(bool enabled)
{
Proxy.git_libgit2_opts_set_enable_ofsdelta(enabled);
}

/// <summary>
/// Enable or disable the libgit2 strict_object_creation capability
/// </summary>
/// <param name="enabled">true to enable the strict_object_creation capability, false otherwise</param>
public static void SetEnableStrictObjectCreation(bool enabled)
{
Proxy.git_libgit2_opts_set_enable_strictobjectcreation(enabled);
}
}
}