Skip to content

Commit ed35167

Browse files
committed
Upgrade libgit2 binaries to 17b06f4
1 parent 99ebe32 commit ed35167

File tree

13 files changed

+51
-33
lines changed

13 files changed

+51
-33
lines changed

Lib/NativeBinaries/amd64/git2.dll

35 KB
Binary file not shown.

Lib/NativeBinaries/amd64/git2.pdb

-320 KB
Binary file not shown.

Lib/NativeBinaries/x86/git2.dll

26 KB
Binary file not shown.

Lib/NativeBinaries/x86/git2.pdb

432 KB
Binary file not shown.

LibGit2Sharp.Tests/RepositoryFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ public void LookingUpWithBadParamsThrows()
339339
}
340340
}
341341

342-
[Fact(Skip = "This test requires an update to libgit2 to pass.")]
342+
[Fact]
343343
public void LookingUpWithATooShortShaThrows()
344344
{
345345
using (var repo = new Repository(BareTestRepoPath))

LibGit2Sharp.Tests/StatusFixture.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public void RetrievingTheStatusOfADirectoryThrows()
2323
{
2424
using (var repo = new Repository(StandardTestRepoPath))
2525
{
26-
Assert.Throws<LibGit2SharpException>(() => { FileStatus status = repo.Index.RetrieveStatus("1"); });
26+
Assert.Throws<AmbiguousException>(() => { FileStatus status = repo.Index.RetrieveStatus("1"); });
2727
}
2828
}
2929

@@ -242,7 +242,7 @@ public void RetrievingTheStatusOfTheRepositoryHonorsTheGitIgnoreDirectives()
242242
}
243243
}
244244

245-
[Fact(Skip = "This test needs libgit2/libgit2@ffbc689")]
245+
[Fact]
246246
public void RetrievingTheStatusOfAnAmbiguousFileThrows()
247247
{
248248
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoWorkingDirPath);
@@ -256,7 +256,7 @@ public void RetrievingTheStatusOfAnAmbiguousFileThrows()
256256
fullFilePath = Path.Combine(repo.Info.WorkingDirectory, relativePath);
257257
File.WriteAllText(fullFilePath, "Brackets all the way.");
258258

259-
repo.Index.RetrieveStatus(relativePath);
259+
Assert.Throws<AmbiguousException>(() => repo.Index.RetrieveStatus(relativePath));
260260
}
261261
}
262262
}

LibGit2Sharp/BranchCollection.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,10 @@ public virtual void Remove(Branch branch)
171171
{
172172
Ensure.ArgumentNotNull(branch, "branch");
173173

174-
this.Remove(branch.Name, branch.IsRemote);
174+
using (ReferenceSafeHandle referencePtr = repo.Refs.RetrieveReferencePtr(branch.CanonicalName))
175+
{
176+
Proxy.git_branch_delete(referencePtr);
177+
}
175178
}
176179

177180
/// <summary>
@@ -202,7 +205,12 @@ public virtual Branch Move(Branch branch, string newName, bool allowOverwrite =
202205
throw new LibGit2SharpException(string.Format("Cannot rename branch '{0}'. It's a remote tracking branch.", branch.Name));
203206
}
204207

205-
return this.Move(branch.Name, newName, allowOverwrite);
208+
using (ReferenceSafeHandle referencePtr = repo.Refs.RetrieveReferencePtr("refs/heads/" + branch.Name))
209+
{
210+
Proxy.git_branch_move(referencePtr, newName, allowOverwrite);
211+
}
212+
213+
return this[newName];
206214
}
207215

208216
private static bool LooksLikeABranchName(string referenceName)

LibGit2Sharp/BranchCollectionExtensions.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,16 @@ public static void Remove(this BranchCollection branches, string name, bool isRe
3535
{
3636
Ensure.ArgumentNotNullOrEmptyString(name, "name");
3737

38-
Proxy.git_branch_delete(branches.repo.Handle, name, isRemote ? GitBranchType.GIT_BRANCH_REMOTE : GitBranchType.GIT_BRANCH_LOCAL);
38+
string branchName = isRemote ? "refs/remotes/" + name : name;
39+
40+
Branch branch = branches[branchName];
41+
42+
if (branch == null)
43+
{
44+
return;
45+
}
46+
47+
branches.Remove(branch);
3948
}
4049

4150
/// <summary>
@@ -51,9 +60,14 @@ public static Branch Move(this BranchCollection branches, string currentName, st
5160
Ensure.ArgumentNotNullOrEmptyString(currentName, "currentName");
5261
Ensure.ArgumentNotNullOrEmptyString(newName, "newName");
5362

54-
Proxy.git_branch_move(branches.repo.Handle, currentName, newName, allowOverwrite);
63+
Branch branch = branches[currentName];
64+
65+
if (branch == null)
66+
{
67+
throw new LibGit2SharpException("No branch named '{0}' exists in the repository.");
68+
}
5569

56-
return branches[newName];
70+
return branches.Move(branch, newName, allowOverwrite);
5771
}
5872
}
5973
}

LibGit2Sharp/Core/NativeMethods.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,7 @@ internal static extern int git_branch_create(
109109

110110
[DllImport(libgit2)]
111111
internal static extern int git_branch_delete(
112-
RepositorySafeHandle repo,
113-
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string branch_name,
114-
GitBranchType branch_type);
112+
ReferenceSafeHandle reference);
115113

116114
internal delegate int branch_foreach_callback(
117115
IntPtr branch_name,
@@ -127,8 +125,7 @@ internal static extern int git_branch_foreach(
127125

128126
[DllImport(libgit2)]
129127
internal static extern int git_branch_move(
130-
RepositorySafeHandle repo,
131-
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string old_branch_name,
128+
ReferenceSafeHandle reference,
132129
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string new_branch_name,
133130
[MarshalAs(UnmanagedType.Bool)] bool force);
134131

@@ -356,7 +353,7 @@ internal static extern int git_index_open(
356353
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath indexpath);
357354

358355
[DllImport(libgit2)]
359-
internal static extern int git_index_read_tree(IndexSafeHandle index, GitObjectSafeHandle tree);
356+
internal static extern int git_index_read_tree(IndexSafeHandle index, GitObjectSafeHandle tree, IntPtr payload);
360357

361358
[DllImport(libgit2)]
362359
internal static extern int git_index_remove(IndexSafeHandle index, int n);
@@ -718,7 +715,7 @@ internal static extern int git_tag_delete(
718715
internal static extern int git_tree_create_fromindex(out GitOid treeOid, IndexSafeHandle index);
719716

720717
[DllImport(libgit2)]
721-
internal static extern uint git_tree_entry_attributes(SafeHandle entry);
718+
internal static extern uint git_tree_entry_filemode(SafeHandle entry);
722719

723720
[DllImport(libgit2)]
724721
internal static extern TreeEntrySafeHandle git_tree_entry_byindex(GitObjectSafeHandle tree, uint idx);

LibGit2Sharp/Core/Proxy.cs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,12 @@ public static GitOid git_branch_create(RepositorySafeHandle repo, string branch_
9494
}
9595
}
9696

97-
public static void git_branch_delete(RepositorySafeHandle repo, string branch_name, GitBranchType branch_type)
97+
public static void git_branch_delete(ReferenceSafeHandle reference)
9898
{
9999
using (ThreadAffinity())
100100
{
101-
int res = NativeMethods.git_branch_delete(repo, branch_name, branch_type);
102-
103-
if (res == (int)GitErrorCode.NotFound)
104-
{
105-
return;
106-
}
107-
101+
int res = NativeMethods.git_branch_delete(reference);
102+
reference.SetHandleAsInvalid();
108103
Ensure.Success(res);
109104
}
110105
}
@@ -121,11 +116,11 @@ public static void git_branch_foreach(
121116
}
122117
}
123118

124-
public static void git_branch_move(RepositorySafeHandle repo, string old_branch_name, string new_branch_name, bool force)
119+
public static void git_branch_move(ReferenceSafeHandle reference, string new_branch_name, bool force)
125120
{
126121
using (ThreadAffinity())
127122
{
128-
int res = NativeMethods.git_branch_move(repo, old_branch_name, new_branch_name, force);
123+
int res = NativeMethods.git_branch_move(reference, new_branch_name, force);
129124
Ensure.Success(res);
130125
}
131126
}
@@ -567,7 +562,7 @@ public static void git_index_read_tree(RepositorySafeHandle repo, IndexSafeHandl
567562
using (ThreadAffinity())
568563
using (var osw = new ObjectSafeWrapper(tree.Id, repo))
569564
{
570-
int res = NativeMethods.git_index_read_tree(index, osw.ObjectPtr);
565+
int res = NativeMethods.git_index_read_tree(index, osw.ObjectPtr, IntPtr.Zero);
571566
Ensure.Success(res);
572567
}
573568
}
@@ -622,9 +617,13 @@ public static string git_message_prettify(string message)
622617
{
623618
using (ThreadAffinity())
624619
{
625-
var buffer = new byte[NativeMethods.GIT_PATH_MAX];
620+
int bufSize = NativeMethods.git_message_prettify(null, 0, message, false);
621+
Ensure.Success(bufSize, true);
622+
623+
var buffer = new byte[bufSize];
624+
626625
int res = NativeMethods.git_message_prettify(buffer, buffer.Length, message, false);
627-
Ensure.Success(res);
626+
Ensure.Success(res, true);
628627

629628
return Utf8Marshaler.Utf8FromBuffer(buffer) ?? string.Empty;
630629
}
@@ -1394,7 +1393,7 @@ public static GitOid git_tree_create_fromindex(Index index)
13941393

13951394
public static Mode git_tree_entry_attributes(SafeHandle entry)
13961395
{
1397-
return (Mode)NativeMethods.git_tree_entry_attributes(entry);
1396+
return (Mode)NativeMethods.git_tree_entry_filemode(entry);
13981397
}
13991398

14001399
public static TreeEntrySafeHandle git_tree_entry_byindex(GitObjectSafeHandle tree, uint idx)

LibGit2Sharp/ReferenceCollection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ private Reference UpdateTarget<T>(Reference reference, T target, Action<Referenc
220220
}
221221
}
222222

223-
private ReferenceSafeHandle RetrieveReferencePtr(string referenceName, bool shouldThrowIfNotFound = true)
223+
internal ReferenceSafeHandle RetrieveReferencePtr(string referenceName, bool shouldThrowIfNotFound = true)
224224
{
225225
ReferenceSafeHandle reference = Proxy.git_reference_lookup(repo.Handle, referenceName, shouldThrowIfNotFound);
226226

LibGit2Sharp/libgit2_hash.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
14e1bc157a06d4513ce4193e6100a338432b3c88
1+
17b06f4d47bfd9fae8073c85d71751df94e50050

libgit2

Submodule libgit2 updated 508 files

0 commit comments

Comments
 (0)