Skip to content

Commit bf3bbbc

Browse files
jamillnulltoken
authored andcommitted
Update libgit2 binaries to 711333e
libgit2/libgit2@11f8336...711333e
1 parent af2f3d8 commit bf3bbbc

19 files changed

+76
-145
lines changed
-796 KB
Binary file not shown.
798 KB
Binary file not shown.
-601 KB
Binary file not shown.
602 KB
Binary file not shown.

LibGit2Sharp/Core/GitCloneOptions.cs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,12 @@ internal class GitCloneOptions
99
public uint Version = 1;
1010

1111
public GitCheckoutOpts CheckoutOpts;
12-
public IntPtr InitOptions;
12+
public GitRemoteCallbacks RemoteCallbacks;
13+
1314
public int Bare;
14-
public NativeMethods.git_transfer_progress_callback TransferProgressCallback;
15-
public IntPtr TransferProgressPayload;
15+
public int IgnoreCertErrors;
1616

1717
public IntPtr RemoteName;
18-
public IntPtr PushUrl;
19-
public IntPtr FetchSpec;
20-
public IntPtr PushSpec;
21-
22-
public NativeMethods.git_cred_acquire_cb CredAcquireCallback;
23-
public IntPtr CredAcquirePayload;
24-
25-
public IntPtr Transport;
26-
public GitRemoteCallbacks RemoteCallbacks;
27-
public int RemoteAutotag;
18+
public IntPtr CheckoutBranch;
2819
}
2920
}

LibGit2Sharp/Core/GitRemoteCallbacks.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ internal struct GitRemoteCallbacks
1515

1616
internal NativeMethods.remote_completion_callback completion;
1717

18+
internal NativeMethods.git_cred_acquire_cb acquire_credentials;
19+
20+
internal NativeMethods.git_transfer_progress_callback download_progress;
21+
1822
internal NativeMethods.remote_update_tips_callback update_tips;
1923

2024
internal IntPtr payload;

LibGit2Sharp/Core/NativeDllName.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ namespace LibGit2Sharp.Core
22
{
33
internal static class NativeDllName
44
{
5-
public const string Name = "git2-11f8336";
5+
public const string Name = "git2-711333e";
66
}
77
}

LibGit2Sharp/Core/NativeMethods.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -783,9 +783,7 @@ internal static extern int git_remote_create(
783783

784784
[DllImport(libgit2)]
785785
internal static extern int git_remote_download(
786-
RemoteSafeHandle remote,
787-
git_transfer_progress_callback progress_cb,
788-
IntPtr payload);
786+
RemoteSafeHandle remote);
789787

790788
[DllImport(libgit2)]
791789
internal static extern void git_remote_free(IntPtr remote);
@@ -815,12 +813,6 @@ internal static extern int git_remote_load(
815813
[DllImport(libgit2)]
816814
internal static extern int git_remote_save(RemoteSafeHandle remote);
817815

818-
[DllImport(libgit2)]
819-
internal static extern void git_remote_set_cred_acquire_cb(
820-
RemoteSafeHandle remote,
821-
git_cred_acquire_cb cred_acquire_cb,
822-
IntPtr payload);
823-
824816
[DllImport(libgit2)]
825817
[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))]
826818
internal static extern string git_remote_url(RemoteSafeHandle remote);

LibGit2Sharp/Core/Proxy.cs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,13 +1406,11 @@ public static GitRefSpecHandle git_remote_get_refspec(RemoteSafeHandle remote, i
14061406
return NativeMethods.git_remote_get_refspec(remote, (UIntPtr)n);
14071407
}
14081408

1409-
public static void git_remote_download(RemoteSafeHandle remote, TransferProgressHandler onTransferProgress)
1409+
public static void git_remote_download(RemoteSafeHandle remote)
14101410
{
14111411
using (ThreadAffinity())
14121412
{
1413-
NativeMethods.git_transfer_progress_callback cb = TransferCallbacks.GenerateCallback(onTransferProgress);
1414-
1415-
int res = NativeMethods.git_remote_download(remote, cb, IntPtr.Zero);
1413+
int res = NativeMethods.git_remote_download(remote);
14161414
Ensure.ZeroResult(res);
14171415
}
14181416
}
@@ -1505,11 +1503,6 @@ public static void git_remote_set_callbacks(RemoteSafeHandle remote, ref GitRemo
15051503
}
15061504
}
15071505

1508-
public static void git_remote_set_cred_acquire_cb(RemoteSafeHandle remote, NativeMethods.git_cred_acquire_cb cred_acquire_cb, IntPtr payload)
1509-
{
1510-
NativeMethods.git_remote_set_cred_acquire_cb(remote, cred_acquire_cb, payload);
1511-
}
1512-
15131506
public static void git_remote_update_tips(RemoteSafeHandle remote)
15141507
{
15151508
using (ThreadAffinity())

LibGit2Sharp/LibGit2Sharp.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@
192192
<Compile Include="Note.cs" />
193193
<Compile Include="RepositoryNotFoundException.cs" />
194194
<Compile Include="TagFetchMode.cs" />
195-
<Compile Include="TransferCallbacks.cs" />
196195
<Compile Include="TransferProgress.cs" />
197196
<Compile Include="TreeChanges.cs" />
198197
<Compile Include="TreeEntryChanges.cs" />

LibGit2Sharp/Network.cs

Lines changed: 5 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -111,32 +111,16 @@ public virtual void Fetch(
111111
{
112112
Ensure.ArgumentNotNull(remote, "remote");
113113

114-
// We need to keep a reference to the git_cred_acquire_cb callback around
115-
// so it will not be garbage collected before we are done with it.
116-
// Note that we also have a GC.KeepAlive call at the end of the method.
117-
NativeMethods.git_cred_acquire_cb credentialCallback = null;
118-
119114
using (RemoteSafeHandle remoteHandle = Proxy.git_remote_load(repository.Handle, remote.Name, true))
120115
{
121-
var callbacks = new RemoteCallbacks(onProgress, onCompletion, onUpdateTips);
116+
var callbacks = new RemoteCallbacks(onProgress, onTransferProgress, onCompletion, onUpdateTips, credentials);
122117
GitRemoteCallbacks gitCallbacks = callbacks.GenerateCallbacks();
123118

124119
if (tagFetchMode.HasValue)
125120
{
126121
Proxy.git_remote_set_autotag(remoteHandle, tagFetchMode.Value);
127122
}
128123

129-
if (credentials != null)
130-
{
131-
credentialCallback = (out IntPtr cred, IntPtr url, IntPtr username_from_url, uint types, IntPtr payload) =>
132-
NativeMethods.git_cred_userpass_plaintext_new(out cred, credentials.Username, credentials.Password);
133-
134-
Proxy.git_remote_set_cred_acquire_cb(
135-
remoteHandle,
136-
credentialCallback,
137-
IntPtr.Zero);
138-
}
139-
140124
// It is OK to pass the reference to the GitCallbacks directly here because libgit2 makes a copy of
141125
// the data in the git_remote_callbacks structure. If, in the future, libgit2 changes its implementation
142126
// to store a reference to the git_remote_callbacks structure this would introduce a subtle bug
@@ -150,18 +134,14 @@ public virtual void Fetch(
150134
try
151135
{
152136
Proxy.git_remote_connect(remoteHandle, GitDirection.Fetch);
153-
Proxy.git_remote_download(remoteHandle, onTransferProgress);
137+
Proxy.git_remote_download(remoteHandle);
154138
Proxy.git_remote_update_tips(remoteHandle);
155139
}
156140
finally
157141
{
158142
Proxy.git_remote_disconnect(remoteHandle);
159143
}
160144
}
161-
162-
// To be safe, make sure the credential callback is kept until
163-
// alive until at least this point.
164-
GC.KeepAlive(credentialCallback);
165145
}
166146

167147
/// <summary>
@@ -222,11 +202,6 @@ public virtual void Push(
222202
Ensure.ArgumentNotNull(remote, "remote");
223203
Ensure.ArgumentNotNull(pushRefSpecs, "pushRefSpecs");
224204

225-
// We need to keep a reference to the git_cred_acquire_cb callback around
226-
// so it will not be garbage collected before we are done with it.
227-
// Note that we also have a GC.KeepAlive call at the end of the method.
228-
NativeMethods.git_cred_acquire_cb credentialCallback = null;
229-
230205
// Return early if there is nothing to push.
231206
if (!pushRefSpecs.Any())
232207
{
@@ -238,16 +213,9 @@ public virtual void Push(
238213
// Load the remote.
239214
using (RemoteSafeHandle remoteHandle = Proxy.git_remote_load(repository.Handle, remote.Name, true))
240215
{
241-
if (credentials != null)
242-
{
243-
credentialCallback = (out IntPtr cred, IntPtr url, IntPtr username_from_url, uint types, IntPtr payload) =>
244-
NativeMethods.git_cred_userpass_plaintext_new(out cred, credentials.Username, credentials.Password);
245-
246-
Proxy.git_remote_set_cred_acquire_cb(
247-
remoteHandle,
248-
credentialCallback,
249-
IntPtr.Zero);
250-
}
216+
var callbacks = new RemoteCallbacks(null, null, null, null, credentials);
217+
GitRemoteCallbacks gitCallbacks = callbacks.GenerateCallbacks();
218+
Proxy.git_remote_set_callbacks(remoteHandle, ref gitCallbacks);
251219

252220
try
253221
{
@@ -279,10 +247,6 @@ public virtual void Push(
279247
Proxy.git_remote_disconnect(remoteHandle);
280248
}
281249
}
282-
283-
// To be safe, make sure the credential callback is kept
284-
// alive until at least this point.
285-
GC.KeepAlive(credentialCallback);
286250
}
287251

288252
/// <summary>

LibGit2Sharp/RemoteCallbacks.cs

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,18 @@ namespace LibGit2Sharp
1212
/// </summary>
1313
internal class RemoteCallbacks
1414
{
15-
internal RemoteCallbacks(ProgressHandler onProgress = null, CompletionHandler onCompletion = null, UpdateTipsHandler onUpdateTips = null)
15+
internal RemoteCallbacks(
16+
ProgressHandler onProgress = null,
17+
TransferProgressHandler onDownloadProgress = null,
18+
CompletionHandler onCompletion = null,
19+
UpdateTipsHandler onUpdateTips = null,
20+
Credentials credentials = null)
1621
{
1722
Progress = onProgress;
23+
DownloadTransferProgress = onDownloadProgress;
1824
Completion = onCompletion;
1925
UpdateTips = onUpdateTips;
26+
Credentials = credentials;
2027
}
2128

2229
#region Delegates
@@ -36,8 +43,19 @@ internal RemoteCallbacks(ProgressHandler onProgress = null, CompletionHandler on
3643
/// </summary>
3744
private readonly CompletionHandler Completion;
3845

46+
/// <summary>
47+
/// Managed delegate to be called in response to a git_transfer_progress_callback callback from libgit2.
48+
/// This will in turn call the user provided delegate.
49+
/// </summary>
50+
private readonly TransferProgressHandler DownloadTransferProgress;
51+
3952
#endregion
4053

54+
/// <summary>
55+
/// The credentials to use for the credential callback.
56+
/// </summary>
57+
Credentials Credentials;
58+
4159
internal GitRemoteCallbacks GenerateCallbacks()
4260
{
4361
var callbacks = new GitRemoteCallbacks {version = 1};
@@ -57,6 +75,16 @@ internal GitRemoteCallbacks GenerateCallbacks()
5775
callbacks.completion = GitCompletionHandler;
5876
}
5977

78+
if (Credentials != null)
79+
{
80+
callbacks.acquire_credentials = GitCredentialHandler;
81+
}
82+
83+
if (DownloadTransferProgress != null)
84+
{
85+
callbacks.download_progress = GitDownloadTransferProgressHandler;
86+
}
87+
6088
return callbacks;
6189
}
6290

@@ -126,6 +154,29 @@ private int GitCompletionHandler(RemoteCompletionType remoteCompletionType, IntP
126154
return result;
127155
}
128156

157+
/// <summary>
158+
/// The delegate with the signature that matches the native git_transfer_progress_callback function's signature.
159+
/// </summary>
160+
/// <param name="progress"><see cref="GitTransferProgress"/> structure containing progress information.</param>
161+
/// <param name="payload">Payload data.</param>
162+
/// <returns>the result of the wrapped <see cref="TransferProgressHandler"/></returns>
163+
private int GitDownloadTransferProgressHandler(ref GitTransferProgress progress, IntPtr payload)
164+
{
165+
int result = 0;
166+
167+
if (DownloadTransferProgress != null)
168+
{
169+
result = DownloadTransferProgress(new TransferProgress(progress));
170+
}
171+
172+
return result;
173+
}
174+
175+
private int GitCredentialHandler(out IntPtr cred, IntPtr url, IntPtr username_from_url, uint types, IntPtr payload)
176+
{
177+
return NativeMethods.git_cred_userpass_plaintext_new(out cred, Credentials.Username, Credentials.Password);
178+
}
179+
129180
#endregion
130181
}
131182
}

LibGit2Sharp/Repository.cs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -559,11 +559,13 @@ public static string Clone(string sourceUrl, string workdirPath,
559559
Credentials credentials = null)
560560
{
561561
CheckoutCallbacks checkoutCallbacks = CheckoutCallbacks.GenerateCheckoutCallbacks(onCheckoutProgress, null);
562+
563+
var callbacks = new RemoteCallbacks(null, onTransferProgress, null, null, credentials);
564+
GitRemoteCallbacks gitCallbacks = callbacks.GenerateCallbacks();
562565

563566
var cloneOpts = new GitCloneOptions
564567
{
565568
Bare = bare ? 1 : 0,
566-
TransferProgressCallback = TransferCallbacks.GenerateCallback(onTransferProgress),
567569
CheckoutOpts =
568570
{
569571
version = 1,
@@ -573,25 +575,15 @@ public static string Clone(string sourceUrl, string workdirPath,
573575
? CheckoutStrategy.GIT_CHECKOUT_SAFE_CREATE
574576
: CheckoutStrategy.GIT_CHECKOUT_NONE
575577
},
578+
RemoteCallbacks = gitCallbacks,
576579
};
577580

578-
if (credentials != null)
579-
{
580-
cloneOpts.CredAcquireCallback =
581-
(out IntPtr cred, IntPtr url, IntPtr username_from_url, uint types, IntPtr payload) =>
582-
NativeMethods.git_cred_userpass_plaintext_new(out cred, credentials.Username, credentials.Password);
583-
}
584-
585581
FilePath repoPath;
586582
using (RepositorySafeHandle repo = Proxy.git_clone(sourceUrl, workdirPath, cloneOpts))
587583
{
588584
repoPath = Proxy.git_repository_path(repo);
589585
}
590586

591-
// To be safe, make sure the credential callback is kept until
592-
// alive until at least this point.
593-
GC.KeepAlive(cloneOpts.CredAcquireCallback);
594-
595587
return repoPath.Native;
596588
}
597589

LibGit2Sharp/TransferCallbacks.cs

Lines changed: 0 additions & 55 deletions
This file was deleted.

LibGit2Sharp/UnbornBranchException.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace LibGit2Sharp
1111
public class UnbornBranchException : LibGit2SharpException
1212
{
1313
/// <summary>
14-
/// Initializes a new instance of the <see cref="OrphanedHeadException"/> class.
14+
/// Initializes a new instance of the <see cref="UnbornBranchException"/> class.
1515
/// </summary>
1616
public UnbornBranchException()
1717
{

LibGit2Sharp/libgit2_hash.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
11f8336ec93ea3a270c9fe80c4bbb68aa4729423
1+
711333efe1c1388c39cd76480273b4fcea18d491

0 commit comments

Comments
 (0)