diff --git a/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj b/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj
index 25e652522..c56b726a7 100644
--- a/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj
+++ b/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj
@@ -1,7 +1,7 @@
- net472;netcoreapp3.1;net6.0
+ net472;netcoreapp3.1;net7.0
diff --git a/LibGit2Sharp/CheckoutCallbacks.cs b/LibGit2Sharp/CheckoutCallbacks.cs
index dc03846bf..e2d2f9484 100644
--- a/LibGit2Sharp/CheckoutCallbacks.cs
+++ b/LibGit2Sharp/CheckoutCallbacks.cs
@@ -1,6 +1,9 @@
using System;
using LibGit2Sharp.Core;
using LibGit2Sharp.Handlers;
+#if __IOS__
+using ObjCRuntime;
+#endif
namespace LibGit2Sharp
{
@@ -10,6 +13,27 @@ namespace LibGit2Sharp
///
internal class CheckoutCallbacks
{
+ #region Static Implementation
+ static CheckoutCallbacks Current;
+
+#if __IOS__
+#pragma warning disable CA1416
+ [MonoPInvokeCallback(typeof(progress_cb))]
+#pragma warning restore CA1416
+#endif
+ internal static void OnStaticCheckoutProgress(IntPtr str, UIntPtr completedSteps, UIntPtr totalSteps, IntPtr payload)
+ => Current?.OnGitCheckoutProgress(str, completedSteps, totalSteps, payload);
+
+#if __IOS__
+#pragma warning disable CA1416
+ [MonoPInvokeCallback(typeof(checkout_notify_cb))]
+#pragma warning restore CA1416
+#endif
+ internal static int OnStaticCheckoutNotify(CheckoutNotifyFlags why, IntPtr pathPtr, IntPtr baselinePtr, IntPtr targetPtr, IntPtr workdirPtr, IntPtr payloadPtr)
+ => Current?.OnGitCheckoutNotify(why, pathPtr, baselinePtr, targetPtr, workdirPtr, payloadPtr) ?? 0;
+#endregion
+
+
///
/// The managed delegate (e.g. from library consumer) to be called in response to the checkout progress callback.
///
@@ -40,7 +64,8 @@ public progress_cb CheckoutProgressCallback
{
if (this.onCheckoutProgress != null)
{
- return this.OnGitCheckoutProgress;
+ //return this.OnGitCheckoutProgress;
+ return OnStaticCheckoutProgress;
}
return null;
@@ -56,7 +81,8 @@ public checkout_notify_cb CheckoutNotifyCallback
{
if (this.onCheckoutNotify != null)
{
- return this.OnGitCheckoutNotify;
+ //return this.OnGitCheckoutNotify;
+ return OnStaticCheckoutNotify;
}
return null;
@@ -71,7 +97,7 @@ public checkout_notify_cb CheckoutNotifyCallback
/// The delegate with signature matching the expected native callback.
internal static CheckoutCallbacks From(CheckoutProgressHandler onCheckoutProgress, CheckoutNotifyHandler onCheckoutNotify)
{
- return new CheckoutCallbacks(onCheckoutProgress, onCheckoutNotify);
+ return Current = new CheckoutCallbacks(onCheckoutProgress, onCheckoutNotify);
}
///
diff --git a/LibGit2Sharp/Commands/Fetch.cs b/LibGit2Sharp/Commands/Fetch.cs
index d61fca5a5..a18b02543 100644
--- a/LibGit2Sharp/Commands/Fetch.cs
+++ b/LibGit2Sharp/Commands/Fetch.cs
@@ -41,8 +41,9 @@ public static void Fetch(Repository repository, string remote, IEnumerable
+
+
+
+ true
+ false
+
+
+ bin\$(MSBuildProjectName)
+ obj\$(MSBuildProjectName)
+ $(DefaultItemExcludes);obj/**;bin/**
+
+ true
+ true
+ true
+ snupkg
+
+ True
+ Ben Askren
+ 42nd Parallel, LLC
+ Convenience classes for Serilog logging
+ 2023, 4nd Parallel
+ https://github.com/baskren/P42.Serilog.QuickLog
+ https://github.com/baskren/P42.Serilog.QuickLog
+ git
+ Inital Public Release
+ LICENSE.md
+ square-logo.png
+ README.md
+
+
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/LibGit2Sharp/GlobalSettings.cs b/LibGit2Sharp/GlobalSettings.cs
index f8db7401a..5d922577d 100644
--- a/LibGit2Sharp/GlobalSettings.cs
+++ b/LibGit2Sharp/GlobalSettings.cs
@@ -44,6 +44,13 @@ static GlobalSettings()
private static string GetExecutingAssemblyDirectory()
{
+#if NET6_0_OR_GREATER || __MOBILE__
+ System.Diagnostics.Debug.WriteLine("GlobalSettings.GetExecutingAssemblyDirectory : ENTER");
+
+ var managedPath = Assembly.GetExecutingAssembly().Location;
+ managedPath = Path.GetDirectoryName(managedPath);
+ return managedPath;
+#else
// Assembly.CodeBase is not actually a correctly formatted
// URI. It's merely prefixed with `file:///` and has its
// backslashes flipped. This is superior to EscapedCodeBase,
@@ -65,6 +72,7 @@ private static string GetExecutingAssemblyDirectory()
managedPath = Path.GetDirectoryName(managedPath);
return managedPath;
+#endif
}
///
diff --git a/LibGit2Sharp/LibGit2Sharp - Backup.csproj b/LibGit2Sharp/LibGit2Sharp - Backup.csproj
new file mode 100644
index 000000000..383a78e26
--- /dev/null
+++ b/LibGit2Sharp/LibGit2Sharp - Backup.csproj
@@ -0,0 +1,64 @@
+
+
+
+ net7.0;net7.0-ios
+ true
+ LibGit2Sharp brings all the might and speed of libgit2, a native Git implementation, to the managed world of .NET
+ LibGit2Sharp contributors
+ Copyright © LibGit2Sharp contributors
+ libgit2 git
+ https://github.com/baskren/libgit2sharp.git
+ LibGit2Sharp contributors
+ true
+ true
+ embedded
+
+ square-logo.png
+ App_Readme/LICENSE.md
+ true
+
+
+
+ 4
+ true
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ https://github.com/libgit2/libgit2sharp/blob/$(GitCommitIdShort)/CHANGES.md#libgit2sharp-changes
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/LibGit2Sharp/LibGit2Sharp.csproj b/LibGit2Sharp/LibGit2Sharp.csproj
index 57c81cdfb..97f9d2309 100644
--- a/LibGit2Sharp/LibGit2Sharp.csproj
+++ b/LibGit2Sharp/LibGit2Sharp.csproj
@@ -1,24 +1,33 @@
- netstandard2.0;netcoreapp3.1
+ net7.0;net7.0-ios
true
LibGit2Sharp brings all the might and speed of libgit2, a native Git implementation, to the managed world of .NET
LibGit2Sharp contributors
Copyright © LibGit2Sharp contributors
libgit2 git
- https://github.com/libgit2/libgit2sharp/
+ https://github.com/baskren/libgit2sharp.git
LibGit2Sharp contributors
true
true
embedded
+
square-logo.png
App_Readme/LICENSE.md
true
+
+ 4
+ true
+
+
+ true
+
@@ -31,8 +40,8 @@
-
-
+
+
@@ -44,4 +53,13 @@
+
+
+
+
+
+
+
+
+
diff --git a/LibGit2Sharp/Network.cs b/LibGit2Sharp/Network.cs
index d5f032058..67c08eca0 100644
--- a/LibGit2Sharp/Network.cs
+++ b/LibGit2Sharp/Network.cs
@@ -122,8 +122,9 @@ private IEnumerable ListReferencesInternal(string url, CredentialsHan
if (credentialsProvider != null)
{
- var callbacks = new RemoteCallbacks(credentialsProvider);
- gitCallbacks = callbacks.GenerateCallbacks();
+ //var callbacks = new RemoteCallbacks(credentialsProvider);
+ //gitCallbacks = callbacks.GenerateCallbacks();
+ gitCallbacks = RemoteCallbacks.GenerateCallbacks(credentialsProvider);
}
Proxy.git_remote_connect(remoteHandle, GitDirection.Fetch, ref gitCallbacks, ref proxyOptions);
@@ -366,8 +367,9 @@ public virtual void Push(Remote remote, IEnumerable pushRefSpecs, PushOp
// Load the remote.
using (RemoteHandle remoteHandle = Proxy.git_remote_lookup(repository.Handle, remote.Name, true))
{
- var callbacks = new RemoteCallbacks(pushOptions);
- GitRemoteCallbacks gitCallbacks = callbacks.GenerateCallbacks();
+ //var callbacks = new RemoteCallbacks(pushOptions);
+ //GitRemoteCallbacks gitCallbacks = callbacks.GenerateCallbacks();
+ var gitCallbacks = RemoteCallbacks.GenerateCallbacks(pushOptions);
Proxy.git_remote_push(remoteHandle,
pushRefSpecs,
diff --git a/LibGit2Sharp/ObjectDatabase.cs b/LibGit2Sharp/ObjectDatabase.cs
index 52aceb321..b58f723d3 100644
--- a/LibGit2Sharp/ObjectDatabase.cs
+++ b/LibGit2Sharp/ObjectDatabase.cs
@@ -318,7 +318,8 @@ private unsafe Blob CreateBlob(Stream stream, string hintpath, long? numberOfByt
catch(Exception e)
{
writestream.free(writestream_ptr);
- throw e;
+ P42.Serilog.QuickLog.QLog.Error(e);
+ throw;
}
ObjectId id = Proxy.git_blob_create_fromstream_commit(writestream_ptr);
diff --git a/LibGit2Sharp/RemoteCallbacks.cs b/LibGit2Sharp/RemoteCallbacks.cs
index ce5dccf81..ea607bbe8 100644
--- a/LibGit2Sharp/RemoteCallbacks.cs
+++ b/LibGit2Sharp/RemoteCallbacks.cs
@@ -1,6 +1,9 @@
using System;
using LibGit2Sharp.Core;
using LibGit2Sharp.Handlers;
+#if __IOS__
+using ObjCRuntime;
+#endif
namespace LibGit2Sharp
{
@@ -12,12 +15,113 @@ namespace LibGit2Sharp
///
internal class RemoteCallbacks
{
- internal RemoteCallbacks(CredentialsHandler credentialsProvider)
+
+#pragma warning disable CA1416
+
+ #region Static Fetch Callbacks
+ static RemoteCallbacks CurrentFetchCallback;
+
+#if __IOS__
+ [MonoPInvokeCallback(typeof(NativeMethods.remote_progress_callback))]
+#endif
+ internal static int StaticFetchProgressHandler(IntPtr str, int len, IntPtr data)
+ => CurrentFetchCallback?.GitProgressHandler(str, len, data) ?? 0;
+
+#if __IOS__
+ [MonoPInvokeCallback(typeof(NativeMethods.git_transfer_progress_callback))]
+#endif
+ internal static int StaticFetchDownloadTransferProgressHandler(ref GitTransferProgress progress, IntPtr payload)
+ => CurrentFetchCallback?.GitDownloadTransferProgressHandler(ref progress, payload) ?? 0;
+
+#if __IOS__
+ [MonoPInvokeCallback(typeof(NativeMethods.remote_update_tips_callback))]
+#endif
+ internal static int StaticFetchUpdateTipsHandler(IntPtr str, ref GitOid oldId, ref GitOid newId, IntPtr data)
+ => CurrentFetchCallback?.GitUpdateTipsHandler(str, ref oldId, ref newId, data) ?? 0;
+
+#if __IOS__
+ [MonoPInvokeCallback(typeof(NativeMethods.git_cred_acquire_cb))]
+#endif
+ internal static int StaticFetchCredentialHandler(out IntPtr ptr, IntPtr cUrl, IntPtr usernameFromUrl, GitCredentialType credTypes, IntPtr payload)
+ {
+ ptr = IntPtr.Zero;
+ return CurrentFetchCallback?.GitCredentialHandler(out ptr, cUrl, usernameFromUrl, credTypes, payload) ?? 0;
+ }
+
+#if __IOS__
+ [MonoPInvokeCallback(typeof(NativeMethods.git_transport_certificate_check_cb))]
+#endif
+ internal static unsafe int StaticFetchCertificateCheck(git_certificate* certPtr, int valid, IntPtr cHostname, IntPtr payload)
+ => CurrentFetchCallback?.GitCertificateCheck(certPtr, valid, cHostname, payload) ?? 0;
+ #endregion
+
+
+ #region Static Push Callbacks
+ static RemoteCallbacks CurrentPushCallback;
+#if __IOS__
+ [MonoPInvokeCallback(typeof(NativeMethods.git_push_transfer_progress))]
+#endif
+ internal static int StaticPushTransferProgressHandler(uint current, uint total, UIntPtr bytes, IntPtr payload)
+ => CurrentPushCallback?.GitPushTransferProgressHandler(current, total, bytes, payload) ?? 0;
+
+#if __IOS__
+ [MonoPInvokeCallback(typeof(NativeMethods.git_packbuilder_progress))]
+#endif
+ internal static int StaticPushPackbuilderProgressHandler(int stage, uint current, uint total, IntPtr payload)
+ => CurrentPushCallback?.GitPackbuilderProgressHandler(stage, current, total, payload) ?? 0;
+
+#if __IOS__
+ [MonoPInvokeCallback(typeof(NativeMethods.git_cred_acquire_cb))]
+#endif
+ internal static int StaticPushCredentialHandler(out IntPtr ptr, IntPtr cUrl, IntPtr usernameFromUrl, GitCredentialType credTypes, IntPtr payload)
+ {
+ ptr = IntPtr.Zero;
+ return CurrentPushCallback?.GitCredentialHandler(out ptr, cUrl, usernameFromUrl, credTypes, payload) ?? 0;
+ }
+
+#if __IOS__
+ [MonoPInvokeCallback(typeof(NativeMethods.git_transport_certificate_check_cb))]
+#endif
+ internal static unsafe int StaticPushCertificateCheck(git_certificate* certPtr, int valid, IntPtr cHostname, IntPtr payload)
+ => CurrentPushCallback?.GitCertificateCheck(certPtr, valid, cHostname, payload) ?? 0;
+
+#if __IOS__
+ [MonoPInvokeCallback(typeof(NativeMethods.push_update_reference_callback))]
+#endif
+ internal static int StaticPushUpdateReference(IntPtr str, IntPtr status, IntPtr data)
+ => CurrentPushCallback?.GitPushUpdateReference(str, status, data) ?? 0;
+
+#if __IOS__
+ [MonoPInvokeCallback(typeof(NativeMethods.push_negotiation_callback))]
+#endif
+ internal static int StaticPushNegotiationHandler(IntPtr updates, UIntPtr len, IntPtr payload)
+ => CurrentPushCallback?.GitPushNegotiationHandler(updates, len, payload) ?? 0;
+ #endregion
+
+
+ #region Static CredentialsHandler Callbacks
+ static RemoteCallbacks CurrentCredientialsCallback;
+
+#if __IOS__
+ [MonoPInvokeCallback(typeof(NativeMethods.git_cred_acquire_cb))]
+#endif
+ internal static int StaticCredentialHandler(out IntPtr ptr, IntPtr cUrl, IntPtr usernameFromUrl, GitCredentialType credTypes, IntPtr payload)
+ {
+ ptr = IntPtr.Zero;
+ return CurrentPushCallback?.GitCredentialHandler(out ptr, cUrl, usernameFromUrl, credTypes, payload) ?? 0;
+ }
+
+ #endregion
+
+#pragma warning restore CA1416
+
+ #region Constructors
+ private RemoteCallbacks(CredentialsHandler credentialsProvider)
{
CredentialsProvider = credentialsProvider;
}
- internal RemoteCallbacks(PushOptions pushOptions)
+ private RemoteCallbacks(PushOptions pushOptions)
{
if (pushOptions == null)
{
@@ -32,7 +136,7 @@ internal RemoteCallbacks(PushOptions pushOptions)
PrePushCallback = pushOptions.OnNegotiationCompletedBeforePush;
}
- internal RemoteCallbacks(FetchOptionsBase fetchOptions)
+ private RemoteCallbacks(FetchOptionsBase fetchOptions)
{
if (fetchOptions == null)
{
@@ -45,6 +149,8 @@ internal RemoteCallbacks(FetchOptionsBase fetchOptions)
CredentialsProvider = fetchOptions.CredentialsProvider;
CertificateCheck = fetchOptions.CertificateCheck;
}
+ #endregion
+
#region Delegates
@@ -97,6 +203,51 @@ internal RemoteCallbacks(FetchOptionsBase fetchOptions)
///
private readonly CertificateCheckHandler CertificateCheck;
+
+ internal static unsafe GitRemoteCallbacks GenerateCallbacks(CredentialsHandler credentialsProvider)
+ {
+ var callbacks = new GitRemoteCallbacks { version = 1 };
+ CurrentCredientialsCallback = new RemoteCallbacks(credentialsProvider);
+ callbacks.acquire_credentials = StaticCredentialHandler;
+ return callbacks;
+ }
+
+ internal static unsafe GitRemoteCallbacks GenerateCallbacks(PushOptions pushOptions)
+ {
+ var callbacks = new GitRemoteCallbacks { version = 1 };
+ CurrentPushCallback = new RemoteCallbacks(pushOptions);
+ if (CurrentPushCallback?.PushTransferProgress != null)
+ callbacks.push_transfer_progress = StaticPushTransferProgressHandler;
+ if (CurrentPushCallback?.PackBuilderProgress != null)
+ callbacks.pack_progress = StaticPushPackbuilderProgressHandler;
+ if (CurrentPushCallback?.CredentialsProvider != null)
+ callbacks.acquire_credentials = StaticPushCredentialHandler;
+ if (CurrentPushCallback?.CertificateCheck != null)
+ callbacks.certificate_check = StaticPushCertificateCheck;
+ if (CurrentPushCallback?.PushStatusError != null)
+ callbacks.push_update_reference = StaticPushUpdateReference;
+ if (CurrentPushCallback?.PrePushCallback != null)
+ callbacks.push_negotiation = StaticPushNegotiationHandler;
+ return callbacks;
+ }
+
+ internal static unsafe GitRemoteCallbacks GenerateCallbacks(FetchOptionsBase fetchOptions)
+ {
+ var callbacks = new GitRemoteCallbacks { version = 1 };
+ CurrentFetchCallback = new RemoteCallbacks(fetchOptions);
+ if (CurrentFetchCallback?.Progress != null)
+ callbacks.progress = StaticFetchProgressHandler;
+ if (CurrentFetchCallback?.DownloadTransferProgress != null)
+ callbacks.download_progress = StaticFetchDownloadTransferProgressHandler;
+ if (CurrentFetchCallback?.UpdateTips != null)
+ callbacks.update_tips = StaticFetchUpdateTipsHandler;
+ if (CurrentFetchCallback?.CredentialsProvider != null)
+ callbacks.acquire_credentials = StaticFetchCredentialHandler;
+ if (CurrentFetchCallback?.CertificateCheck != null)
+ callbacks.certificate_check = StaticFetchCertificateCheck;
+ return callbacks;
+ }
+
internal unsafe GitRemoteCallbacks GenerateCallbacks()
{
var callbacks = new GitRemoteCallbacks { version = 1 };
diff --git a/LibGit2Sharp/Repository.cs b/LibGit2Sharp/Repository.cs
index 41aaecfbf..75fabf8cd 100644
--- a/LibGit2Sharp/Repository.cs
+++ b/LibGit2Sharp/Repository.cs
@@ -682,8 +682,9 @@ public static IEnumerable ListRemoteReferences(string url, Credential
if (credentialsProvider != null)
{
- var callbacks = new RemoteCallbacks(credentialsProvider);
- gitCallbacks = callbacks.GenerateCallbacks();
+ //var callbacks = new RemoteCallbacks(credentialsProvider);
+ //gitCallbacks = callbacks.GenerateCallbacks();
+ gitCallbacks = RemoteCallbacks.GenerateCallbacks(credentialsProvider);
}
Proxy.git_remote_connect(remoteHandle, GitDirection.Fetch, ref gitCallbacks, ref proxyOptions);
@@ -769,7 +770,8 @@ public static string Clone(string sourceUrl, string workdirPath,
var gitFetchOptions = fetchOptionsWrapper.Options;
gitFetchOptions.ProxyOptions = new GitProxyOptions { Version = 1 };
- gitFetchOptions.RemoteCallbacks = new RemoteCallbacks(options).GenerateCallbacks();
+ //gitFetchOptions.RemoteCallbacks = new RemoteCallbacks(options).GenerateCallbacks();
+ gitFetchOptions.RemoteCallbacks = RemoteCallbacks.GenerateCallbacks(options);
if (options.FetchOptions != null && options.FetchOptions.CustomHeaders != null)
{
gitFetchOptions.CustomHeaders =
diff --git a/LibGit2Sharp/SubmoduleCollection.cs b/LibGit2Sharp/SubmoduleCollection.cs
index fc508107a..96bcf0106 100644
--- a/LibGit2Sharp/SubmoduleCollection.cs
+++ b/LibGit2Sharp/SubmoduleCollection.cs
@@ -97,8 +97,9 @@ public virtual void Update(string name, SubmoduleUpdateOptions options)
{
var gitCheckoutOptions = checkoutOptionsWrapper.Options;
- var remoteCallbacks = new RemoteCallbacks(options);
- var gitRemoteCallbacks = remoteCallbacks.GenerateCallbacks();
+ //var remoteCallbacks = new RemoteCallbacks(options);
+ //var gitRemoteCallbacks = remoteCallbacks.GenerateCallbacks();
+ var gitRemoteCallbacks = RemoteCallbacks.GenerateCallbacks(options);
var gitSubmoduleUpdateOpts = new GitSubmoduleUpdateOptions
{
diff --git a/Targets/GenerateNativeDllName.targets b/Targets/GenerateNativeDllName.targets
index 244b707b4..ce5219233 100644
--- a/Targets/GenerateNativeDllName.targets
+++ b/Targets/GenerateNativeDllName.targets
@@ -13,13 +13,17 @@
- namespace LibGit2Sharp.Core
- {
- internal static class NativeDllName
- {
- public const string Name = "$(libgit2_filename)"%3b
- }
- }
+namespace LibGit2Sharp.Core
+{
+ internal static class NativeDllName
+ {
+#if __IOS__
+ public const string Name = "__Internal"%3b
+#else
+ public const string Name = "$(libgit2_filename)"%3b
+#endif
+ }
+}