Permalink
Browse files

Update libgit2 binaries to eef7e80

  • Loading branch information...
1 parent 4606cf0 commit ce5ccef5f16762aac93ef90030911c3b483a44d1 @ethomson ethomson committed Mar 6, 2013
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -103,7 +103,7 @@ public void CallsProgressCallbacks(string url)
var scd = BuildSelfCleaningDirectory();
using (Repository repo = Repository.Clone(url, scd.RootedDirectoryPath,
- onTransferProgress: (_) => transferWasCalled = true,
+ onTransferProgress: (_) => { transferWasCalled = true; return 0; },
onCheckoutProgress: (a, b, c) => checkoutWasCalled = true))
{
Assert.True(transferWasCalled);
View
@@ -216,10 +216,7 @@ private string RemoteNameFromLocalBranch()
private string RemoteNameFromRemoteTrackingBranch()
{
- using (ReferenceSafeHandle branchPtr = repo.Refs.RetrieveReferencePtr(CanonicalName))
- {
- return Proxy.git_branch_remote_name(repo.Handle, branchPtr);
- }
+ return Proxy.git_branch_remote_name(repo.Handle, CanonicalName);
}
/// <summary>
@@ -184,7 +184,9 @@ public virtual Branch Move(Branch branch, string newName, bool allowOverwrite =
using (ReferenceSafeHandle referencePtr = repo.Refs.RetrieveReferencePtr("refs/heads/" + branch.Name))
{
- Proxy.git_branch_move(referencePtr, newName, allowOverwrite);
+ using (ReferenceSafeHandle ref_out = Proxy.git_branch_move(referencePtr, newName, allowOverwrite))
+ {
+ }
}
return this[newName];
@@ -108,10 +108,7 @@ private void GetUpstreamInformation(string canonicalName, out string remoteName,
}
else if (canonicalName.StartsWith(remotePrefix, StringComparison.Ordinal))
{
- using (ReferenceSafeHandle branchPtr = repo.Refs.RetrieveReferencePtr(canonicalName))
- {
- remoteName = Proxy.git_branch_remote_name(repo.Handle, branchPtr);
- }
+ remoteName = Proxy.git_branch_remote_name(repo.Handle, canonicalName);
Remote remote = repo.Network.Remotes.RemoteForName(remoteName);
using (RemoteSafeHandle remoteHandle = Proxy.git_remote_load(repo.Handle, remote.Name, true))
@@ -193,12 +193,9 @@ public void Dispose()
[Flags]
internal enum GitDiffFileFlags
{
- GIT_DIFF_FILE_VALID_OID = (1 << 0),
- GIT_DIFF_FILE_FREE_PATH = (1 << 1),
- GIT_DIFF_FILE_BINARY = (1 << 2),
- GIT_DIFF_FILE_NOT_BINARY = (1 << 3),
- GIT_DIFF_FILE_FREE_DATA = (1 << 4),
- GIT_DIFF_FILE_UNMAP_DATA = (1 << 5),
+ GIT_DIFF_FLAG_BINARY = (1 << 0),
+ GIT_DIFF_FLAG_NOT_BINARY = (1 << 1),
+ GIT_DIFF_FLAG_VALID_OID = (1 << 2),
}
[StructLayout(LayoutKind.Sequential)]
@@ -218,7 +215,7 @@ internal class GitDiffDelta
public GitDiffFile NewFile;
public ChangeKind Status;
public uint Similarity;
- public int Binary;
+ public uint Flags;
}
[StructLayout(LayoutKind.Sequential)]
@@ -7,8 +7,8 @@ internal static class GitDiffExtensions
public static bool IsBinary(this GitDiffDelta delta)
{
//TODO Fix the interop issue on amd64 and use GitDiffDelta.Binary
- return delta.OldFile.Flags.HasFlag(GitDiffFileFlags.GIT_DIFF_FILE_BINARY)
- || delta.NewFile.Flags.HasFlag(GitDiffFileFlags.GIT_DIFF_FILE_BINARY);
+ return delta.OldFile.Flags.HasFlag(GitDiffFileFlags.GIT_DIFF_FLAG_BINARY)
+ || delta.NewFile.Flags.HasFlag(GitDiffFileFlags.GIT_DIFF_FLAG_BINARY);
}
}
}
@@ -137,6 +137,7 @@ private static bool IsRunningOnLinux()
[DllImport(libgit2)]
internal static extern int git_branch_move(
+ out ReferenceSafeHandle ref_out,
ReferenceSafeHandle reference,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string new_branch_name,
[MarshalAs(UnmanagedType.Bool)] bool force);
@@ -146,7 +147,7 @@ private static bool IsRunningOnLinux()
byte[] remote_name_out,
UIntPtr buffer_size,
RepositorySafeHandle repo,
- ReferenceSafeHandle branch);
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string canonical_branch_name);
[DllImport(libgit2)]
internal static extern int git_branch_tracking_name(
@@ -648,6 +649,7 @@ private static bool IsRunningOnLinux()
[DllImport(libgit2)]
internal static extern int git_reference_rename(
+ out ReferenceSafeHandle ref_out,
ReferenceSafeHandle reference,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string newName,
[MarshalAs(UnmanagedType.Bool)] bool force);
@@ -656,10 +658,11 @@ private static bool IsRunningOnLinux()
internal static extern int git_reference_resolve(out ReferenceSafeHandle resolvedReference, ReferenceSafeHandle reference);
[DllImport(libgit2)]
- internal static extern int git_reference_set_target(ReferenceSafeHandle reference, ref GitOid id);
+ internal static extern int git_reference_set_target(out ReferenceSafeHandle ref_out, ReferenceSafeHandle reference, ref GitOid id);
[DllImport(libgit2)]
internal static extern int git_reference_symbolic_set_target(
+ out ReferenceSafeHandle ref_out,
ReferenceSafeHandle reference,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string target);
@@ -986,7 +989,7 @@ private static bool IsRunningOnLinux()
[DllImport(libgit2)]
internal static extern void git_threads_shutdown();
- internal delegate void git_transfer_progress_callback(ref GitTransferProgress stats, IntPtr payload);
+ internal delegate int git_transfer_progress_callback(ref GitTransferProgress stats, IntPtr payload);
[DllImport(libgit2)]
internal static extern uint git_tree_entry_filemode(SafeHandle entry);
View
@@ -135,25 +135,27 @@ public static void git_branch_delete(ReferenceSafeHandle reference)
return git_foreach(resultSelector, c => NativeMethods.git_branch_foreach(repo, branch_type, (x, y, p) => c(x, y, p), IntPtr.Zero));
}
- public static void git_branch_move(ReferenceSafeHandle reference, string new_branch_name, bool force)
+ public static ReferenceSafeHandle git_branch_move(ReferenceSafeHandle reference, string new_branch_name, bool force)
{
using (ThreadAffinity())
{
- int res = NativeMethods.git_branch_move(reference, new_branch_name, force);
+ ReferenceSafeHandle ref_out;
+ int res = NativeMethods.git_branch_move(out ref_out, reference, new_branch_name, force);
Ensure.ZeroResult(res);
+ return ref_out;
}
}
- public static string git_branch_remote_name(RepositorySafeHandle repo, ReferenceSafeHandle branch)
+ public static string git_branch_remote_name(RepositorySafeHandle repo, string canonical_branch_name)
{
using (ThreadAffinity())
{
- int bufSize = NativeMethods.git_branch_remote_name(null, UIntPtr.Zero, repo, branch);
+ int bufSize = NativeMethods.git_branch_remote_name(null, UIntPtr.Zero, repo, canonical_branch_name);
Ensure.Int32Result(bufSize);
var buffer = new byte[bufSize];
- int res = NativeMethods.git_branch_remote_name(buffer, (UIntPtr)buffer.Length, repo, branch);
+ int res = NativeMethods.git_branch_remote_name(buffer, (UIntPtr)buffer.Length, repo, canonical_branch_name);
Ensure.Int32Result(res);
return Utf8Marshaler.Utf8FromBuffer(buffer) ?? string.Empty;
@@ -1124,8 +1126,6 @@ public static void git_reference_delete(ReferenceSafeHandle reference)
using (ThreadAffinity())
{
int res = NativeMethods.git_reference_delete(reference);
- reference.SetHandleAsInvalid();
-
Ensure.ZeroResult(res);
}
}
@@ -1192,12 +1192,16 @@ public static ObjectId git_reference_oid(ReferenceSafeHandle reference)
return NativeMethods.git_reference_target(reference).MarshalAsObjectId();
}
- public static void git_reference_rename(ReferenceSafeHandle reference, string newName, bool allowOverwrite)
+ public static ReferenceSafeHandle git_reference_rename(ReferenceSafeHandle reference, string newName, bool allowOverwrite)
{
using (ThreadAffinity())
{
- int res = NativeMethods.git_reference_rename(reference, newName, allowOverwrite);
+ ReferenceSafeHandle ref_out;
+
+ int res = NativeMethods.git_reference_rename(out ref_out, reference, newName, allowOverwrite);
Ensure.ZeroResult(res);
+
+ return ref_out;
}
}
@@ -1219,22 +1223,30 @@ public static ReferenceSafeHandle git_reference_resolve(ReferenceSafeHandle refe
}
}
- public static void git_reference_set_oid(ReferenceSafeHandle reference, ObjectId id)
+ public static ReferenceSafeHandle git_reference_set_target(ReferenceSafeHandle reference, ObjectId id)
{
using (ThreadAffinity())
{
GitOid oid = id.Oid;
- int res = NativeMethods.git_reference_set_target(reference, ref oid);
+ ReferenceSafeHandle ref_out;
+
+ int res = NativeMethods.git_reference_set_target(out ref_out, reference, ref oid);
Ensure.ZeroResult(res);
+
+ return ref_out;
}
}
- public static void git_reference_set_target(ReferenceSafeHandle reference, string target)
+ public static ReferenceSafeHandle git_reference_symbolic_set_target(ReferenceSafeHandle reference, string target)
{
using (ThreadAffinity())
{
- int res = NativeMethods.git_reference_symbolic_set_target(reference, target);
+ ReferenceSafeHandle ref_out;
+
+ int res = NativeMethods.git_reference_symbolic_set_target(out ref_out, reference, target);
Ensure.ZeroResult(res);
+
+ return ref_out;
}
}
View
@@ -23,6 +23,7 @@ private GitDiffOptions BuildOptions(DiffOptions diffOptions, IEnumerable<string>
var options = new GitDiffOptions();
options.Flags |= GitDiffOptionFlags.GIT_DIFF_INCLUDE_TYPECHANGE;
+ options.ContextLines = 3;
if (diffOptions.HasFlag(DiffOptions.IncludeUntracked))
{
View
@@ -30,7 +30,8 @@
/// Delegate definition for transfer progress callback.
/// </summary>
/// <param name="progress">The <see cref = "TransferProgress" /> object containing progress information.</param>
- public delegate void TransferProgressHandler(TransferProgress progress);
+ /// <returns>Return negative integer to cancel.</returns>
+ public delegate int TransferProgressHandler(TransferProgress progress);
/// <summary>
/// Delegate definition to handle reporting errors when updating references on the remote.
@@ -153,9 +153,10 @@ public virtual Reference Move(Reference reference, string newName, bool allowOve
using (ReferenceSafeHandle handle = RetrieveReferencePtr(reference.CanonicalName))
{
- Proxy.git_reference_rename(handle, newName, allowOverwrite);
-
- return Reference.BuildFromPtr<Reference>(handle, repo);
+ using (ReferenceSafeHandle handle_out = Proxy.git_reference_rename(handle, newName, allowOverwrite))
+ {
+ return Reference.BuildFromPtr<Reference>(handle_out, repo);
+ }
}
}
@@ -181,7 +182,7 @@ public virtual Reference UpdateTarget(Reference directRef, ObjectId targetId)
Ensure.ArgumentNotNull(targetId, "targetId");
return UpdateTarget(directRef, targetId,
- (h, id) => Proxy.git_reference_set_oid(h, id));
+ (h, id) => Proxy.git_reference_set_target(h, id));
}
/// <summary>
@@ -196,10 +197,10 @@ public virtual Reference UpdateTarget(Reference symbolicRef, Reference targetRef
Ensure.ArgumentNotNull(targetRef, "targetRef");
return UpdateTarget(symbolicRef, targetRef,
- (h, r) => Proxy.git_reference_set_target(h, r.CanonicalName));
+ (h, r) => Proxy.git_reference_symbolic_set_target(h, r.CanonicalName));
}
- private Reference UpdateTarget<T>(Reference reference, T target, Action<ReferenceSafeHandle, T> setter)
+ private Reference UpdateTarget<T>(Reference reference, T target, Func<ReferenceSafeHandle, T, ReferenceSafeHandle> setter)
{
if (reference.CanonicalName == "HEAD")
{
@@ -219,8 +220,10 @@ private Reference UpdateTarget<T>(Reference reference, T target, Action<Referenc
using (ReferenceSafeHandle referencePtr = RetrieveReferencePtr(reference.CanonicalName))
{
- setter(referencePtr, target);
- return Reference.BuildFromPtr<Reference>(referencePtr, repo);
+ using (ReferenceSafeHandle ref_out = setter(referencePtr, target))
+ {
+ return Reference.BuildFromPtr<Reference>(ref_out, repo);
+ }
}
}
@@ -46,9 +46,10 @@ internal static NativeMethods.git_transfer_progress_callback GenerateCallback(Tr
/// </summary>
/// <param name="progress"><see cref = "GitTransferProgress" /> structure containing progress information.</param>
/// <param name="payload">Payload data.</param>
- private void OnGitTransferProgress(ref GitTransferProgress progress, IntPtr payload)
+ /// <returns>the result of the wrapped <see cref = "TransferProgressHandler" /></returns>
+ private int OnGitTransferProgress(ref GitTransferProgress progress, IntPtr payload)
{
- onTransferProgress(new TransferProgress(progress));
+ return onTransferProgress(new TransferProgress(progress));
}
}
}
@@ -1 +1 @@
-40a605104c2060c2bc5a08dfb62cafe473baeb21
+eef7e80e68a530f8ce1d1ec196d41fc33a1ced6e
Submodule libgit2 updated 206 files

0 comments on commit ce5ccef

Please sign in to comment.