Skip to content

Commit

Permalink
Merge pull request #1905 from jairbubbles/update-to-libgit-1-1-1
Browse files Browse the repository at this point in the history
Update LibGit2 to version 1.1.1
  • Loading branch information
bording committed Aug 24, 2021
2 parents f5098f4 + 9941d39 commit 6329bea
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 38 deletions.
2 changes: 1 addition & 1 deletion LibGit2Sharp.Tests/CloneFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private void AssertLocalClone(string url, string path = null, bool isCloningAnEm
Assert.NotEqual(originalRepo.Info.Path, clonedRepo.Info.Path);
Assert.Equal(originalRepo.Head, clonedRepo.Head);

Assert.Equal(originalRepo.Branches.Count(), clonedRepo.Branches.Count(b => b.IsRemote));
Assert.Equal(originalRepo.Branches.Count(), clonedRepo.Branches.Count(b => b.IsRemote && b.FriendlyName != "origin/HEAD"));
Assert.Equal(isCloningAnEmptyRepository ? 0 : 1, clonedRepo.Branches.Count(b => !b.IsRemote));

Assert.Equal(originalRepo.Tags.Count(), clonedRepo.Tags.Count());
Expand Down
8 changes: 4 additions & 4 deletions LibGit2Sharp.Tests/FetchFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public void FetchHonorsTheFetchPruneConfigurationEntry()

using (var clonedRepo = new Repository(clonedRepoPath))
{
Assert.Equal(5, clonedRepo.Branches.Count(b => b.IsRemote));
Assert.Equal(5, clonedRepo.Branches.Count(b => b.IsRemote && b.FriendlyName != "origin/HEAD"));

// Drop one of the branches in the remote repository
using (var sourceRepo = new Repository(source))
Expand All @@ -226,17 +226,17 @@ public void FetchHonorsTheFetchPruneConfigurationEntry()
// No pruning when the configuration entry isn't defined
Assert.Null(clonedRepo.Config.Get<bool>("fetch.prune"));
Commands.Fetch(clonedRepo, "origin", new string[0], null, null);
Assert.Equal(5, clonedRepo.Branches.Count(b => b.IsRemote));
Assert.Equal(5, clonedRepo.Branches.Count(b => b.IsRemote && b.FriendlyName != "origin/HEAD"));

// No pruning when the configuration entry is set to false
clonedRepo.Config.Set<bool>("fetch.prune", false);
Commands.Fetch(clonedRepo, "origin", new string[0], null, null);
Assert.Equal(5, clonedRepo.Branches.Count(b => b.IsRemote));
Assert.Equal(5, clonedRepo.Branches.Count(b => b.IsRemote && b.FriendlyName != "origin/HEAD"));

// Auto pruning when the configuration entry is set to true
clonedRepo.Config.Set<bool>("fetch.prune", true);
Commands.Fetch(clonedRepo, "origin", new string[0], null, null);
Assert.Equal(4, clonedRepo.Branches.Count(b => b.IsRemote));
Assert.Equal(4, clonedRepo.Branches.Count(b => b.IsRemote && b.FriendlyName != "origin/HEAD"));
}
}

Expand Down
20 changes: 10 additions & 10 deletions LibGit2Sharp/Core/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ private sealed class NativeShutdownObject : CriticalFinalizerObject
internal static extern unsafe GitError* git_error_last();

[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern void git_error_set_str(
internal static extern int git_error_set_str(
GitErrorCategory error_class,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string errorString);

Expand All @@ -252,25 +252,25 @@ private sealed class NativeShutdownObject : CriticalFinalizerObject
internal static extern unsafe void git_blame_free(git_blame* blame);

[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_blob_create_fromdisk(
internal static extern unsafe int git_blob_create_from_disk(
ref GitOid id,
git_repository* repo,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictFilePathMarshaler))] FilePath path);

[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_blob_create_fromworkdir(
internal static extern unsafe int git_blob_create_from_workdir(
ref GitOid id,
git_repository* repo,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictFilePathMarshaler))] FilePath relative_path);

[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe int git_blob_create_fromstream(
internal static extern unsafe int git_blob_create_from_stream(
out IntPtr stream,
git_repository* repositoryPtr,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string hintpath);

[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern int git_blob_create_fromstream_commit(
internal static extern int git_blob_create_from_stream_commit(
ref GitOid oid,
IntPtr stream);

Expand Down Expand Up @@ -1616,7 +1616,7 @@ IntPtr data
internal static extern unsafe FilePath git_repository_path(git_repository* repository);

[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe void git_repository_set_config(
internal static extern unsafe int git_repository_set_config(
git_repository* repository,
git_config* config);

Expand All @@ -1628,7 +1628,7 @@ IntPtr data


[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe void git_repository_set_index(
internal static extern unsafe int git_repository_set_index(
git_repository* repository,
git_index* index);

Expand Down Expand Up @@ -1710,13 +1710,13 @@ IntPtr data
internal static extern unsafe int git_revwalk_push(git_revwalk* walker, ref GitOid id);

[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe void git_revwalk_reset(git_revwalk* walker);
internal static extern unsafe int git_revwalk_reset(git_revwalk* walker);

[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe void git_revwalk_sorting(git_revwalk* walk, CommitSortStrategies sort);
internal static extern unsafe int git_revwalk_sorting(git_revwalk* walk, CommitSortStrategies sort);

[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe void git_revwalk_simplify_first_parent(git_revwalk* walk);
internal static extern unsafe int git_revwalk_simplify_first_parent(git_revwalk* walk);

[DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe void git_signature_free(git_signature* signature);
Expand Down
39 changes: 20 additions & 19 deletions LibGit2Sharp/Core/Proxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,34 +36,34 @@ internal class Proxy

#region git_blob_

public static unsafe IntPtr git_blob_create_fromstream(RepositoryHandle repo, string hintpath)
public static unsafe IntPtr git_blob_create_from_stream(RepositoryHandle repo, string hintpath)
{
IntPtr writestream_ptr;

Ensure.ZeroResult(NativeMethods.git_blob_create_fromstream(out writestream_ptr, repo, hintpath));
Ensure.ZeroResult(NativeMethods.git_blob_create_from_stream(out writestream_ptr, repo, hintpath));
return writestream_ptr;
}

public static unsafe ObjectId git_blob_create_fromstream_commit(IntPtr writestream_ptr)
{
var oid = new GitOid();
Ensure.ZeroResult(NativeMethods.git_blob_create_fromstream_commit(ref oid, writestream_ptr));
Ensure.ZeroResult(NativeMethods.git_blob_create_from_stream_commit(ref oid, writestream_ptr));
return oid;
}

public static unsafe ObjectId git_blob_create_fromdisk(RepositoryHandle repo, FilePath path)
public static unsafe ObjectId git_blob_create_from_disk(RepositoryHandle repo, FilePath path)
{
var oid = new GitOid();
int res = NativeMethods.git_blob_create_fromdisk(ref oid, repo, path);
int res = NativeMethods.git_blob_create_from_disk(ref oid, repo, path);
Ensure.ZeroResult(res);

return oid;
}

public static unsafe ObjectId git_blob_create_fromfile(RepositoryHandle repo, FilePath path)
public static unsafe ObjectId git_blob_create_from_workdir(RepositoryHandle repo, FilePath path)
{
var oid = new GitOid();
int res = NativeMethods.git_blob_create_fromworkdir(ref oid, repo, path);
int res = NativeMethods.git_blob_create_from_workdir(ref oid, repo, path);
Ensure.ZeroResult(res);

return oid;
Expand Down Expand Up @@ -855,21 +855,22 @@ public static unsafe int git_diff_num_deltas(DiffHandle diff)

#region git_error_

public static void git_error_set_str(GitErrorCategory error_class, Exception exception)
public static int git_error_set_str(GitErrorCategory error_class, Exception exception)
{
if (exception is OutOfMemoryException)
{
NativeMethods.git_error_set_oom();
return 0;
}
else
{
NativeMethods.git_error_set_str(error_class, ErrorMessageFromException(exception));
return NativeMethods.git_error_set_str(error_class, ErrorMessageFromException(exception));
}
}

public static void git_error_set_str(GitErrorCategory error_class, String errorString)
public static int git_error_set_str(GitErrorCategory error_class, String errorString)
{
NativeMethods.git_error_set_str(error_class, errorString);
return NativeMethods.git_error_set_str(error_class, errorString);
}

/// <summary>
Expand Down Expand Up @@ -2589,9 +2590,9 @@ public static unsafe FilePath git_repository_path(RepositoryHandle repo)
return NativeMethods.git_repository_path(repo);
}

public static unsafe void git_repository_set_config(RepositoryHandle repo, ConfigurationHandle config)
public static unsafe int git_repository_set_config(RepositoryHandle repo, ConfigurationHandle config)
{
NativeMethods.git_repository_set_config(repo, config);
return NativeMethods.git_repository_set_config(repo, config);
}

public static unsafe void git_repository_set_ident(RepositoryHandle repo, string name, string email)
Expand All @@ -2600,9 +2601,9 @@ public static unsafe void git_repository_set_ident(RepositoryHandle repo, string
Ensure.ZeroResult(res);
}

public static unsafe void git_repository_set_index(RepositoryHandle repo, IndexHandle index)
public static unsafe int git_repository_set_index(RepositoryHandle repo, IndexHandle index)
{
NativeMethods.git_repository_set_index(repo, index);
return NativeMethods.git_repository_set_index(repo, index);
}

public static unsafe void git_repository_set_workdir(RepositoryHandle repo, FilePath workdir)
Expand Down Expand Up @@ -2783,14 +2784,14 @@ public static unsafe void git_revwalk_reset(RevWalkerHandle walker)
NativeMethods.git_revwalk_reset(walker);
}

public static unsafe void git_revwalk_sorting(RevWalkerHandle walker, CommitSortStrategies options)
public static unsafe int git_revwalk_sorting(RevWalkerHandle walker, CommitSortStrategies options)
{
NativeMethods.git_revwalk_sorting(walker, options);
return NativeMethods.git_revwalk_sorting(walker, options);
}

public static unsafe void git_revwalk_simplify_first_parent(RevWalkerHandle walker)
public static unsafe int git_revwalk_simplify_first_parent(RevWalkerHandle walker)
{
NativeMethods.git_revwalk_simplify_first_parent(walker);
return NativeMethods.git_revwalk_simplify_first_parent(walker);
}

#endregion
Expand Down
2 changes: 1 addition & 1 deletion LibGit2Sharp/LibGit2Sharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="LibGit2Sharp.NativeBinaries" Version="[2.0.314]" PrivateAssets="none" />
<PackageReference Include="LibGit2Sharp.NativeBinaries" Version="[2.0.315-alpha.0.1]" PrivateAssets="none" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="all" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.4.220" PrivateAssets="all" />
</ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions LibGit2Sharp/ObjectDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ public virtual Blob CreateBlob(string path)
}

ObjectId id = Path.IsPathRooted(path)
? Proxy.git_blob_create_fromdisk(repo.Handle, path)
: Proxy.git_blob_create_fromfile(repo.Handle, path);
? Proxy.git_blob_create_from_disk(repo.Handle, path)
: Proxy.git_blob_create_from_workdir(repo.Handle, path);

return repo.Lookup<Blob>(id);
}
Expand Down Expand Up @@ -277,7 +277,7 @@ private unsafe Blob CreateBlob(Stream stream, string hintpath, long? numberOfByt
throw new ArgumentException("The stream cannot be read from.", "stream");
}

IntPtr writestream_ptr = Proxy.git_blob_create_fromstream(repo.Handle, hintpath);
IntPtr writestream_ptr = Proxy.git_blob_create_from_stream(repo.Handle, hintpath);
GitWriteStream writestream = Marshal.PtrToStructure<GitWriteStream>(writestream_ptr);

try
Expand Down

0 comments on commit 6329bea

Please sign in to comment.