Skip to content
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
1 change: 1 addition & 0 deletions LibGit2Sharp/Core/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ private static IntPtr ResolveDll(string libraryName, Assembly assembly, DllImpor
{
Trace.TraceInformation("Using git with schannel");
libraryName = libraryName + "_schannel";
GlobalSettings.SetHttpBackend(HttpsBackend.Schannel);
}

// Use GlobalSettings.NativeLibraryPath when set.
Expand Down
39 changes: 39 additions & 0 deletions LibGit2Sharp/GlobalSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public static class GlobalSettings
private static string nativeLibraryPath;
private static bool nativeLibraryPathLocked;
private static readonly string nativeLibraryDefaultPath = null;
private static HttpsBackend httpsBackend = HttpsBackend.WinHttp;

static GlobalSettings()
{
Expand Down Expand Up @@ -420,5 +421,43 @@ public static string GetUserAgent()
{
return Proxy.git_libgit2_opts_get_user_agent();
}

/// <summary>
/// Check libgit supported features
/// </summary>
public static bool HasFeature(LibGitFeature feature)
{
return feature switch
{
LibGitFeature.DefaultCredentials => httpsBackend == HttpsBackend.WinHttp,
_ => false
};
}

internal static void SetHttpBackend(HttpsBackend backend)
{
httpsBackend = backend;
}
}

/// <summary>
/// List of supported libgit features
/// </summary>
public enum LibGitFeature
{
/// <summary>
/// Not used
/// </summary>
None,
/// <summary>
/// When supported, returning 'null' from the credentials manager acts as fallback attempt like using Windows authentication for WinHttp transport
/// </summary>
DefaultCredentials
}

internal enum HttpsBackend
{
WinHttp,
Schannel
}
}