Skip to content
This repository was archived by the owner on Feb 3, 2023. It is now read-only.

Commit b9d7e79

Browse files
committed
Make GitCloneOptions a struct to fix issue libgit2#635
1 parent 8e5f6cf commit b9d7e79

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

LibGit2Sharp/Core/GitCloneOptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
namespace LibGit2Sharp.Core
55
{
66
[StructLayout(LayoutKind.Sequential)]
7-
internal class GitCloneOptions
7+
internal struct GitCloneOptions
88
{
9-
public uint Version = 1;
9+
public uint Version;
1010

1111
public GitCheckoutOpts CheckoutOpts;
1212
public GitRemoteCallbacks RemoteCallbacks;

LibGit2Sharp/Core/NativeMethods.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ internal static extern int git_clone(
238238
out RepositorySafeHandle repo,
239239
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string origin_url,
240240
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictFilePathMarshaler))] FilePath workdir_path,
241-
GitCloneOptions opts);
241+
ref GitCloneOptions opts);
242242

243243
[DllImport(libgit2)]
244244
internal static extern IntPtr git_commit_author(GitObjectSafeHandle commit);

LibGit2Sharp/Core/Proxy.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,12 +278,12 @@ public static void git_checkout_index(RepositorySafeHandle repo, GitObjectSafeHa
278278
public static RepositorySafeHandle git_clone(
279279
string url,
280280
string workdir,
281-
GitCloneOptions opts)
281+
ref GitCloneOptions opts)
282282
{
283283
using (ThreadAffinity())
284284
{
285285
RepositorySafeHandle repo;
286-
int res = NativeMethods.git_clone(out repo, url, workdir, opts);
286+
int res = NativeMethods.git_clone(out repo, url, workdir, ref opts);
287287
Ensure.ZeroResult(res);
288288
return repo;
289289
}

LibGit2Sharp/Repository.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,7 @@ public static string Clone(string sourceUrl, string workdirPath,
558558

559559
var cloneOpts = new GitCloneOptions
560560
{
561+
Version = 1,
561562
Bare = options.IsBare ? 1 : 0,
562563
CheckoutOpts =
563564
{
@@ -572,7 +573,7 @@ public static string Clone(string sourceUrl, string workdirPath,
572573
};
573574

574575
FilePath repoPath;
575-
using (RepositorySafeHandle repo = Proxy.git_clone(sourceUrl, workdirPath, cloneOpts))
576+
using (RepositorySafeHandle repo = Proxy.git_clone(sourceUrl, workdirPath, ref cloneOpts))
576577
{
577578
repoPath = Proxy.git_repository_path(repo);
578579
}

0 commit comments

Comments
 (0)