Skip to content

Commit be2be63

Browse files
committed
Update Proxy and NativeMethods in preperation for Fetch.
1 parent 00c61ba commit be2be63

File tree

4 files changed

+88
-9
lines changed

4 files changed

+88
-9
lines changed

LibGit2Sharp/Core/GitIndexerStats.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
namespace LibGit2Sharp.Core
44
{
55
[StructLayout(LayoutKind.Sequential)]
6-
internal class GitIndexerStats
6+
internal struct GitIndexerStats
77
{
8-
public int Total;
9-
public int Processed;
10-
public int Received;
8+
public uint Total;
9+
public uint Processed;
10+
public uint Received;
1111
}
1212
}

LibGit2Sharp/Core/NativeMethods.cs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ internal static extern int git_checkout_tree(
147147
RepositorySafeHandle repo,
148148
GitObjectSafeHandle treeish,
149149
GitCheckoutOpts opts,
150-
GitIndexerStats stats);
150+
ref GitIndexerStats stats);
151151

152152
[DllImport(libgit2)]
153153
internal static extern IntPtr git_commit_author(GitObjectSafeHandle commit);
@@ -583,6 +583,34 @@ internal static extern int git_remote_new(
583583
[DllImport(libgit2)]
584584
internal static extern int git_repository_odb(out ObjectDatabaseSafeHandle odb, RepositorySafeHandle repo);
585585

586+
[DllImport(libgit2)]
587+
internal static extern int git_remote_connect(RemoteSafeHandle remote, GitDirection direction);
588+
589+
[DllImport(libgit2)]
590+
internal static extern void git_remote_disconnect(RemoteSafeHandle remote);
591+
592+
[DllImport(libgit2)]
593+
internal static extern int git_remote_download(RemoteSafeHandle remote, ref long bytes, ref GitIndexerStats stats);
594+
595+
[DllImport(libgit2)]
596+
internal static extern void git_remote_set_autotag(RemoteSafeHandle remote, TagOption option);
597+
598+
[DllImport(libgit2)]
599+
internal static extern void git_remote_set_callbacks(RemoteSafeHandle remote, ref GitRemoteCallbacks callbacks);
600+
601+
internal delegate void remote_progress_callback(IntPtr str, int len, IntPtr data);
602+
603+
internal delegate int remote_completion_callback(RemoteCompletionType type, IntPtr data);
604+
605+
internal delegate int remote_update_tips_callback(
606+
IntPtr refName,
607+
ref GitOid oldId,
608+
ref GitOid newId,
609+
IntPtr data);
610+
611+
[DllImport(libgit2)]
612+
internal static extern int git_remote_update_tips(RemoteSafeHandle remote);
613+
586614
[DllImport(libgit2)]
587615
internal static extern int git_repository_discover(
588616
byte[] repository_path, // NB: This is more properly a StringBuilder, but it's UTF8

LibGit2Sharp/Core/Proxy.cs

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,12 @@ public static void git_checkout_tree(
172172
RepositorySafeHandle repo,
173173
ObjectId treeId,
174174
GitCheckoutOpts opts,
175-
GitIndexerStats stats)
175+
ref GitIndexerStats stats)
176176
{
177177
using (ThreadAffinity())
178178
using (var osw = new ObjectSafeWrapper(treeId, repo))
179179
{
180-
int res = NativeMethods.git_checkout_tree(repo, osw.ObjectPtr, opts, stats);
180+
int res = NativeMethods.git_checkout_tree(repo, osw.ObjectPtr, opts, ref stats);
181181
Ensure.Success(res);
182182
}
183183
}
@@ -1039,6 +1039,32 @@ public static RemoteSafeHandle git_remote_add(RepositorySafeHandle repo, string
10391039
}
10401040
}
10411041

1042+
public static void git_remote_connect(RemoteSafeHandle remote, GitDirection direction)
1043+
{
1044+
using (ThreadAffinity())
1045+
{
1046+
int res = NativeMethods.git_remote_connect(remote, direction);
1047+
Ensure.Success(res);
1048+
}
1049+
}
1050+
1051+
public static void git_remote_disconnect(RemoteSafeHandle remote)
1052+
{
1053+
using (ThreadAffinity())
1054+
{
1055+
NativeMethods.git_remote_disconnect(remote);
1056+
}
1057+
}
1058+
1059+
public static void git_remote_download(RemoteSafeHandle remote, ref long bytes, ref GitIndexerStats indexerStats)
1060+
{
1061+
using (ThreadAffinity())
1062+
{
1063+
int res = NativeMethods.git_remote_download(remote, ref bytes, ref indexerStats);
1064+
Ensure.Success(res);
1065+
}
1066+
}
1067+
10421068
public static void git_remote_free(IntPtr remote)
10431069
{
10441070
NativeMethods.git_remote_free(remote);
@@ -1099,6 +1125,31 @@ public static void git_remote_save(RemoteSafeHandle remote)
10991125
}
11001126
}
11011127

1128+
public static void git_remote_set_autotag(RemoteSafeHandle remote, TagOption value)
1129+
{
1130+
using (ThreadAffinity())
1131+
{
1132+
NativeMethods.git_remote_set_autotag(remote, value);
1133+
}
1134+
}
1135+
1136+
public static void git_remote_set_callbacks(RemoteSafeHandle remote, ref GitRemoteCallbacks callbacks)
1137+
{
1138+
using (ThreadAffinity())
1139+
{
1140+
NativeMethods.git_remote_set_callbacks(remote, ref callbacks);
1141+
}
1142+
}
1143+
1144+
public static void git_remote_update_tips(RemoteSafeHandle remote)
1145+
{
1146+
using (ThreadAffinity())
1147+
{
1148+
int res = NativeMethods.git_remote_update_tips(remote);
1149+
Ensure.Success(res);
1150+
}
1151+
}
1152+
11021153
public static string git_remote_url(RemoteSafeHandle remote)
11031154
{
11041155
return NativeMethods.git_remote_url(remote);

LibGit2Sharp/Repository.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,8 +437,8 @@ private void CheckoutTreeForce(ObjectId treeId)
437437
CheckoutStrategy.GIT_CHECKOUT_OVERWRITE_MODIFIED |
438438
CheckoutStrategy.GIT_CHECKOUT_REMOVE_UNTRACKED
439439
};
440-
441-
Proxy.git_checkout_tree(handle, treeId, opts, null);
440+
GitIndexerStats stats = new GitIndexerStats();
441+
Proxy.git_checkout_tree(handle, treeId, opts, ref stats);
442442
}
443443

444444
/// <summary>

0 commit comments

Comments
 (0)