Skip to content

Commit 9aa7a33

Browse files
committed
Moar
1 parent beea5df commit 9aa7a33

10 files changed

+42
-32
lines changed

LibGit2Sharp/Core/GitFetchOptions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,10 @@ internal class GitFetchOptions
1010
public FetchPruneStrategy prune;
1111
public bool update_fetchhead = true;
1212
public TagFetchMode download_tags;
13+
14+
public GitFetchOptions()
15+
{
16+
download_tags = TagFetchMode.Auto;
17+
}
1318
}
1419
}

LibGit2Sharp/Core/GitPushUpdate.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
using System.Runtime.InteropServices;
3+
4+
namespace LibGit2Sharp.Core
5+
{
6+
[StructLayout(LayoutKind.Sequential)]
7+
internal class GitPushUpdate
8+
{
9+
IntPtr src_refname;
10+
IntPtr dst_refname;
11+
GitOid src;
12+
GitOid dst;
13+
}
14+
}

LibGit2Sharp/Core/GitSmartSubtransportRegistration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ internal class GitSmartSubtransportRegistration
1212

1313
public delegate int create_callback(
1414
out IntPtr subtransport,
15-
IntPtr transport,
15+
IntPtr owner,
1616
IntPtr param);
1717
}
1818
}

LibGit2Sharp/Core/GitSubmoduleOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ internal struct GitSubmoduleOptions
99

1010
public GitCheckoutOpts CheckoutOptions;
1111

12-
public GitRemoteCallbacks RemoteCallbacks;
12+
public GitFetchOptions FetchOptions;
1313

1414
public CheckoutStrategy CloneCheckoutStrategy;
1515
}

LibGit2Sharp/Core/NativeMethods.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,11 +1114,6 @@ internal static extern void git_remote_set_autotag(
11141114
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string name,
11151115
TagFetchMode option);
11161116

1117-
[DllImport(libgit2)]
1118-
internal static extern int git_remote_set_callbacks(
1119-
RemoteSafeHandle remote,
1120-
ref GitRemoteCallbacks callbacks);
1121-
11221117
internal delegate int remote_progress_callback(IntPtr str, int len, IntPtr data);
11231118

11241119
internal delegate int remote_completion_callback(RemoteCompletionType type, IntPtr data);
@@ -1130,8 +1125,8 @@ internal delegate int remote_update_tips_callback(
11301125
IntPtr data);
11311126

11321127
internal delegate int push_negotiation_callback(
1133-
IntPtr updates,
1134-
IntPtr len,
1128+
IntPtr updates, // GitPushUpdate?
1129+
UIntPtr len,
11351130
IntPtr payload
11361131
);
11371132

LibGit2Sharp/Core/Proxy.cs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2008,11 +2008,11 @@ public static RemoteSafeHandle git_remote_create_anonymous(RepositorySafeHandle
20082008
}
20092009
}
20102010

2011-
public static void git_remote_connect(RemoteSafeHandle remote, GitDirection direction)
2011+
public static void git_remote_connect(RemoteSafeHandle remote, GitDirection direction, ref GitRemoteCallbacks remoteCallbacks)
20122012
{
20132013
using (ThreadAffinity())
20142014
{
2015-
int res = NativeMethods.git_remote_connect(remote, direction);
2015+
int res = NativeMethods.git_remote_connect(remote, direction, ref remoteCallbacks);
20162016
Ensure.ZeroResult(res);
20172017
}
20182018
}
@@ -2168,15 +2168,15 @@ public static void git_remote_set_pushurl(RepositorySafeHandle repo, string remo
21682168
}
21692169
}
21702170

2171-
public static void git_remote_fetch(RemoteSafeHandle remote, string logMessage)
2171+
public static void git_remote_fetch(RemoteSafeHandle remote, GitFetchOptions fetchOptions, string logMessage)
21722172
{
21732173
using (ThreadAffinity())
21742174
{
21752175
var array = new GitStrArrayNative();
21762176

21772177
try
21782178
{
2179-
int res = NativeMethods.git_remote_fetch(remote, ref array.Array, logMessage);
2179+
int res = NativeMethods.git_remote_fetch(remote, ref array.Array, fetchOptions, logMessage);
21802180
Ensure.ZeroResult(res);
21812181
}
21822182
finally
@@ -2326,15 +2326,6 @@ public static void git_remote_set_autotag(RepositorySafeHandle repo, string remo
23262326
NativeMethods.git_remote_set_autotag(repo, remote, value);
23272327
}
23282328

2329-
public static void git_remote_set_callbacks(RemoteSafeHandle remote, ref GitRemoteCallbacks callbacks)
2330-
{
2331-
using (ThreadAffinity())
2332-
{
2333-
int res = NativeMethods.git_remote_set_callbacks(remote, ref callbacks);
2334-
Ensure.ZeroResult(res);
2335-
}
2336-
}
2337-
23382329
public static string git_remote_url(RemoteSafeHandle remote)
23392330
{
23402331
return NativeMethods.git_remote_url(remote);

LibGit2Sharp/LibGit2Sharp.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
<Compile Include="CompareOptions.cs" />
7272
<Compile Include="Core\FileHistory.cs" />
7373
<Compile Include="Core\GitFetchOptions.cs" />
74+
<Compile Include="Core\GitPushUpdate.cs" />
7475
<Compile Include="Core\Platform.cs" />
7576
<Compile Include="Core\Handles\ConflictIteratorSafeHandle.cs" />
7677
<Compile Include="DescribeOptions.cs" />

LibGit2Sharp/Network.cs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,15 @@ public virtual IEnumerable<DirectReference> ListReferences(Remote remote, Creden
7272

7373
using (RemoteSafeHandle remoteHandle = Proxy.git_remote_lookup(repository.Handle, remote.Name, true))
7474
{
75+
GitRemoteCallbacks gitCallbacks = new GitRemoteCallbacks();
76+
7577
if (credentialsProvider != null)
7678
{
7779
var callbacks = new RemoteCallbacks(credentialsProvider);
78-
GitRemoteCallbacks gitCallbacks = callbacks.GenerateCallbacks();
79-
Proxy.git_remote_set_callbacks(remoteHandle, ref gitCallbacks);
80+
gitCallbacks = callbacks.GenerateCallbacks();
8081
}
8182

82-
Proxy.git_remote_connect(remoteHandle, GitDirection.Fetch);
83+
Proxy.git_remote_connect(remoteHandle, GitDirection.Fetch, ref gitCallbacks);
8384
return Proxy.git_remote_ls(repository, remoteHandle);
8485
}
8586
}
@@ -101,7 +102,8 @@ public virtual IEnumerable<DirectReference> ListReferences(string url)
101102

102103
using (RemoteSafeHandle remoteHandle = Proxy.git_remote_create_anonymous(repository.Handle, url, null))
103104
{
104-
Proxy.git_remote_connect(remoteHandle, GitDirection.Fetch);
105+
GitRemoteCallbacks gitCallbacks = new GitRemoteCallbacks();
106+
Proxy.git_remote_connect(remoteHandle, GitDirection.Fetch, ref gitCallbacks);
105107
return Proxy.git_remote_ls(repository, remoteHandle);
106108
}
107109
}
@@ -156,9 +158,12 @@ static void DoFetch(RepositorySafeHandle repoHandle, Remote remote, string url,
156158
//
157159
// Also, if GitRemoteCallbacks were a class instead of a struct, we would need to guard against
158160
// GC occuring in between setting the remote callbacks and actual usage in one of the functions afterwords.
159-
Proxy.git_remote_set_callbacks(remoteHandle, ref gitCallbacks);
161+
var fetchOptions = new GitFetchOptions
162+
{
163+
RemoteCallbacks = gitCallbacks
164+
};
160165

161-
Proxy.git_remote_fetch(remoteHandle, logMessage);
166+
Proxy.git_remote_fetch(remoteHandle, fetchOptions, logMessage);
162167
}
163168
}
164169

@@ -419,11 +424,10 @@ public virtual void Push(
419424
{
420425
var callbacks = new RemoteCallbacks(pushOptions);
421426
GitRemoteCallbacks gitCallbacks = callbacks.GenerateCallbacks();
422-
Proxy.git_remote_set_callbacks(remoteHandle, ref gitCallbacks);
423427

424428
try
425429
{
426-
Proxy.git_remote_connect(remoteHandle, GitDirection.Push);
430+
Proxy.git_remote_connect(remoteHandle, GitDirection.Push, ref gitCallbacks);
427431
Proxy.git_remote_push(remoteHandle, pushRefSpecs,
428432
new GitPushOptions()
429433
{

LibGit2Sharp/Repository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ public static string Clone(string sourceUrl, string workdirPath,
628628
Version = 1,
629629
Bare = options.IsBare ? 1 : 0,
630630
CheckoutOpts = gitCheckoutOptions,
631-
RemoteCallbacks = gitRemoteCallbacks,
631+
FetchOpts = new GitFetchOptions { RemoteCallbacks = gitRemoteCallbacks },
632632
};
633633

634634
string clonedRepoPath;

LibGit2Sharp/SubmoduleCollection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public virtual void Update(string name, SubmoduleUpdateOptions options)
107107
{
108108
Version = 1,
109109
CheckoutOptions = gitCheckoutOptions,
110-
RemoteCallbacks = gitRemoteCallbacks,
110+
FetchOptions = new GitFetchOptions { RemoteCallbacks = gitRemoteCallbacks },
111111
CloneCheckoutStrategy = CheckoutStrategy.GIT_CHECKOUT_SAFE
112112
};
113113

0 commit comments

Comments
 (0)