Skip to content

Commit 44cfa26

Browse files
committed
Moar
1 parent aa52a93 commit 44cfa26

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
@@ -56,14 +56,15 @@ public virtual IEnumerable<DirectReference> ListReferences(Remote remote, Creden
5656

5757
using (RemoteSafeHandle remoteHandle = Proxy.git_remote_lookup(repository.Handle, remote.Name, true))
5858
{
59+
GitRemoteCallbacks gitCallbacks = new GitRemoteCallbacks();
60+
5961
if (credentialsProvider != null)
6062
{
6163
var callbacks = new RemoteCallbacks(credentialsProvider);
62-
GitRemoteCallbacks gitCallbacks = callbacks.GenerateCallbacks();
63-
Proxy.git_remote_set_callbacks(remoteHandle, ref gitCallbacks);
64+
gitCallbacks = callbacks.GenerateCallbacks();
6465
}
6566

66-
Proxy.git_remote_connect(remoteHandle, GitDirection.Fetch);
67+
Proxy.git_remote_connect(remoteHandle, GitDirection.Fetch, ref gitCallbacks);
6768
return Proxy.git_remote_ls(repository, remoteHandle);
6869
}
6970
}
@@ -85,7 +86,8 @@ public virtual IEnumerable<DirectReference> ListReferences(string url)
8586

8687
using (RemoteSafeHandle remoteHandle = Proxy.git_remote_create_anonymous(repository.Handle, url, null))
8788
{
88-
Proxy.git_remote_connect(remoteHandle, GitDirection.Fetch);
89+
GitRemoteCallbacks gitCallbacks = new GitRemoteCallbacks();
90+
Proxy.git_remote_connect(remoteHandle, GitDirection.Fetch, ref gitCallbacks);
8991
return Proxy.git_remote_ls(repository, remoteHandle);
9092
}
9193
}
@@ -140,9 +142,12 @@ static void DoFetch(RepositorySafeHandle repoHandle, Remote remote, string url,
140142
//
141143
// Also, if GitRemoteCallbacks were a class instead of a struct, we would need to guard against
142144
// GC occuring in between setting the remote callbacks and actual usage in one of the functions afterwords.
143-
Proxy.git_remote_set_callbacks(remoteHandle, ref gitCallbacks);
145+
var fetchOptions = new GitFetchOptions
146+
{
147+
RemoteCallbacks = gitCallbacks
148+
};
144149

145-
Proxy.git_remote_fetch(remoteHandle, logMessage);
150+
Proxy.git_remote_fetch(remoteHandle, fetchOptions, logMessage);
146151
}
147152
}
148153

@@ -263,11 +268,10 @@ public virtual void Push(
263268
{
264269
var callbacks = new RemoteCallbacks(pushOptions);
265270
GitRemoteCallbacks gitCallbacks = callbacks.GenerateCallbacks();
266-
Proxy.git_remote_set_callbacks(remoteHandle, ref gitCallbacks);
267271

268272
try
269273
{
270-
Proxy.git_remote_connect(remoteHandle, GitDirection.Push);
274+
Proxy.git_remote_connect(remoteHandle, GitDirection.Push, ref gitCallbacks);
271275
Proxy.git_remote_push(remoteHandle, pushRefSpecs,
272276
new GitPushOptions()
273277
{

LibGit2Sharp/Repository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ public static string Clone(string sourceUrl, string workdirPath,
589589
Version = 1,
590590
Bare = options.IsBare ? 1 : 0,
591591
CheckoutOpts = gitCheckoutOptions,
592-
RemoteCallbacks = gitRemoteCallbacks,
592+
FetchOpts = new GitFetchOptions { RemoteCallbacks = gitRemoteCallbacks },
593593
};
594594

595595
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)