Browse files

Upgrade libgit2 binaries to 17b06f4

  • Loading branch information...
1 parent 99ebe32 commit ed351670e491c362403bfcf156cb4329d8b21546 @nulltoken nulltoken committed Sep 10, 2012
View
BIN Lib/NativeBinaries/amd64/git2.dll
Binary file not shown.
View
BIN Lib/NativeBinaries/amd64/git2.pdb
Binary file not shown.
View
BIN Lib/NativeBinaries/x86/git2.dll
Binary file not shown.
View
BIN Lib/NativeBinaries/x86/git2.pdb
Binary file not shown.
View
2 LibGit2Sharp.Tests/RepositoryFixture.cs
@@ -339,7 +339,7 @@ public void LookingUpWithBadParamsThrows()
}
}
- [Fact(Skip = "This test requires an update to libgit2 to pass.")]
+ [Fact]
public void LookingUpWithATooShortShaThrows()
{
using (var repo = new Repository(BareTestRepoPath))
View
6 LibGit2Sharp.Tests/StatusFixture.cs
@@ -23,7 +23,7 @@ public void RetrievingTheStatusOfADirectoryThrows()
{
using (var repo = new Repository(StandardTestRepoPath))
{
- Assert.Throws<LibGit2SharpException>(() => { FileStatus status = repo.Index.RetrieveStatus("1"); });
+ Assert.Throws<AmbiguousException>(() => { FileStatus status = repo.Index.RetrieveStatus("1"); });
}
}
@@ -242,7 +242,7 @@ public void RetrievingTheStatusOfTheRepositoryHonorsTheGitIgnoreDirectives()
}
}
- [Fact(Skip = "This test needs libgit2/libgit2@ffbc689")]
+ [Fact]
public void RetrievingTheStatusOfAnAmbiguousFileThrows()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoWorkingDirPath);
@@ -256,7 +256,7 @@ public void RetrievingTheStatusOfAnAmbiguousFileThrows()
fullFilePath = Path.Combine(repo.Info.WorkingDirectory, relativePath);
File.WriteAllText(fullFilePath, "Brackets all the way.");
- repo.Index.RetrieveStatus(relativePath);
+ Assert.Throws<AmbiguousException>(() => repo.Index.RetrieveStatus(relativePath));
}
}
}
View
12 LibGit2Sharp/BranchCollection.cs
@@ -171,7 +171,10 @@ public virtual void Remove(Branch branch)
{
Ensure.ArgumentNotNull(branch, "branch");
- this.Remove(branch.Name, branch.IsRemote);
+ using (ReferenceSafeHandle referencePtr = repo.Refs.RetrieveReferencePtr(branch.CanonicalName))
+ {
+ Proxy.git_branch_delete(referencePtr);
+ }
}
/// <summary>
@@ -202,7 +205,12 @@ public virtual Branch Move(Branch branch, string newName, bool allowOverwrite =
throw new LibGit2SharpException(string.Format("Cannot rename branch '{0}'. It's a remote tracking branch.", branch.Name));
}
- return this.Move(branch.Name, newName, allowOverwrite);
+ using (ReferenceSafeHandle referencePtr = repo.Refs.RetrieveReferencePtr("refs/heads/" + branch.Name))
+ {
+ Proxy.git_branch_move(referencePtr, newName, allowOverwrite);
+ }
+
+ return this[newName];
}
private static bool LooksLikeABranchName(string referenceName)
View
20 LibGit2Sharp/BranchCollectionExtensions.cs
@@ -35,7 +35,16 @@ public static void Remove(this BranchCollection branches, string name, bool isRe
{
Ensure.ArgumentNotNullOrEmptyString(name, "name");
- Proxy.git_branch_delete(branches.repo.Handle, name, isRemote ? GitBranchType.GIT_BRANCH_REMOTE : GitBranchType.GIT_BRANCH_LOCAL);
+ string branchName = isRemote ? "refs/remotes/" + name : name;
+
+ Branch branch = branches[branchName];
+
+ if (branch == null)
+ {
+ return;
+ }
+
+ branches.Remove(branch);
}
/// <summary>
@@ -51,9 +60,14 @@ public static Branch Move(this BranchCollection branches, string currentName, st
Ensure.ArgumentNotNullOrEmptyString(currentName, "currentName");
Ensure.ArgumentNotNullOrEmptyString(newName, "newName");
- Proxy.git_branch_move(branches.repo.Handle, currentName, newName, allowOverwrite);
+ Branch branch = branches[currentName];
+
+ if (branch == null)
+ {
+ throw new LibGit2SharpException("No branch named '{0}' exists in the repository.");
+ }
- return branches[newName];
+ return branches.Move(branch, newName, allowOverwrite);
}
}
}
View
11 LibGit2Sharp/Core/NativeMethods.cs
@@ -109,9 +109,7 @@ private static bool IsRunningOnLinux()
[DllImport(libgit2)]
internal static extern int git_branch_delete(
- RepositorySafeHandle repo,
- [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string branch_name,
- GitBranchType branch_type);
+ ReferenceSafeHandle reference);
internal delegate int branch_foreach_callback(
IntPtr branch_name,
@@ -127,8 +125,7 @@ private static bool IsRunningOnLinux()
[DllImport(libgit2)]
internal static extern int git_branch_move(
- RepositorySafeHandle repo,
- [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string old_branch_name,
+ ReferenceSafeHandle reference,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string new_branch_name,
[MarshalAs(UnmanagedType.Bool)] bool force);
@@ -356,7 +353,7 @@ private static bool IsRunningOnLinux()
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath indexpath);
[DllImport(libgit2)]
- internal static extern int git_index_read_tree(IndexSafeHandle index, GitObjectSafeHandle tree);
+ internal static extern int git_index_read_tree(IndexSafeHandle index, GitObjectSafeHandle tree, IntPtr payload);
[DllImport(libgit2)]
internal static extern int git_index_remove(IndexSafeHandle index, int n);
@@ -718,7 +715,7 @@ private static bool IsRunningOnLinux()
internal static extern int git_tree_create_fromindex(out GitOid treeOid, IndexSafeHandle index);
[DllImport(libgit2)]
- internal static extern uint git_tree_entry_attributes(SafeHandle entry);
+ internal static extern uint git_tree_entry_filemode(SafeHandle entry);
[DllImport(libgit2)]
internal static extern TreeEntrySafeHandle git_tree_entry_byindex(GitObjectSafeHandle tree, uint idx);
View
27 LibGit2Sharp/Core/Proxy.cs
@@ -94,17 +94,12 @@ public static GitOid git_branch_create(RepositorySafeHandle repo, string branch_
}
}
- public static void git_branch_delete(RepositorySafeHandle repo, string branch_name, GitBranchType branch_type)
+ public static void git_branch_delete(ReferenceSafeHandle reference)
{
using (ThreadAffinity())
{
- int res = NativeMethods.git_branch_delete(repo, branch_name, branch_type);
-
- if (res == (int)GitErrorCode.NotFound)
- {
- return;
- }
-
+ int res = NativeMethods.git_branch_delete(reference);
+ reference.SetHandleAsInvalid();
Ensure.Success(res);
}
}
@@ -121,11 +116,11 @@ public static void git_branch_delete(RepositorySafeHandle repo, string branch_na
}
}
- public static void git_branch_move(RepositorySafeHandle repo, string old_branch_name, string new_branch_name, bool force)
+ public static void git_branch_move(ReferenceSafeHandle reference, string new_branch_name, bool force)
{
using (ThreadAffinity())
{
- int res = NativeMethods.git_branch_move(repo, old_branch_name, new_branch_name, force);
+ int res = NativeMethods.git_branch_move(reference, new_branch_name, force);
Ensure.Success(res);
}
}
@@ -567,7 +562,7 @@ public static void git_index_read_tree(RepositorySafeHandle repo, IndexSafeHandl
using (ThreadAffinity())
using (var osw = new ObjectSafeWrapper(tree.Id, repo))
{
- int res = NativeMethods.git_index_read_tree(index, osw.ObjectPtr);
+ int res = NativeMethods.git_index_read_tree(index, osw.ObjectPtr, IntPtr.Zero);
Ensure.Success(res);
}
}
@@ -622,9 +617,13 @@ public static string git_message_prettify(string message)
{
using (ThreadAffinity())
{
- var buffer = new byte[NativeMethods.GIT_PATH_MAX];
+ int bufSize = NativeMethods.git_message_prettify(null, 0, message, false);
+ Ensure.Success(bufSize, true);
+
+ var buffer = new byte[bufSize];
+
int res = NativeMethods.git_message_prettify(buffer, buffer.Length, message, false);
- Ensure.Success(res);
+ Ensure.Success(res, true);
return Utf8Marshaler.Utf8FromBuffer(buffer) ?? string.Empty;
}
@@ -1394,7 +1393,7 @@ public static GitOid git_tree_create_fromindex(Index index)
public static Mode git_tree_entry_attributes(SafeHandle entry)
{
- return (Mode)NativeMethods.git_tree_entry_attributes(entry);
+ return (Mode)NativeMethods.git_tree_entry_filemode(entry);
}
public static TreeEntrySafeHandle git_tree_entry_byindex(GitObjectSafeHandle tree, uint idx)
View
2 LibGit2Sharp/ReferenceCollection.cs
@@ -220,7 +220,7 @@ private Reference UpdateTarget<T>(Reference reference, T target, Action<Referenc
}
}
- private ReferenceSafeHandle RetrieveReferencePtr(string referenceName, bool shouldThrowIfNotFound = true)
+ internal ReferenceSafeHandle RetrieveReferencePtr(string referenceName, bool shouldThrowIfNotFound = true)
{
ReferenceSafeHandle reference = Proxy.git_reference_lookup(repo.Handle, referenceName, shouldThrowIfNotFound);
View
2 LibGit2Sharp/libgit2_hash.txt
@@ -1 +1 @@
-???14e1bc157a06d4513ce4193e6100a338432b3c88
+???17b06f4d47bfd9fae8073c85d71751df94e50050
2 libgit2
@@ -1 +1 @@
-Subproject commit 14e1bc157a06d4513ce4193e6100a338432b3c88
+Subproject commit 17b06f4d47bfd9fae8073c85d71751df94e50050

0 comments on commit ed35167

Please sign in to comment.