Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed Lib/NativeBinaries/amd64/git2-3f8d005.dll
Binary file not shown.
Binary file added Lib/NativeBinaries/amd64/git2-4eb97ef.dll
Binary file not shown.
Binary file not shown.
Binary file removed Lib/NativeBinaries/x86/git2-3f8d005.dll
Binary file not shown.
Binary file added Lib/NativeBinaries/x86/git2-4eb97ef.dll
Binary file not shown.
Binary file not shown.
6 changes: 3 additions & 3 deletions LibGit2Sharp.Tests/BranchFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,9 @@ public void CreatingABranchFromANonCommitObjectThrows()
using (var repo = new Repository(BareTestRepoPath))
{
const string name = "sorry-dude-i-do-not-do-blobs-nor-trees";
Assert.Throws<LibGit2SharpException>(() => repo.CreateBranch(name, "refs/tags/point_to_blob"));
Assert.Throws<LibGit2SharpException>(() => repo.CreateBranch(name, "53fc32d"));
Assert.Throws<LibGit2SharpException>(() => repo.CreateBranch(name, "0266163"));
Assert.Throws<InvalidSpecificationException>(() => repo.CreateBranch(name, "refs/tags/point_to_blob"));
Assert.Throws<InvalidSpecificationException>(() => repo.CreateBranch(name, "53fc32d"));
Assert.Throws<InvalidSpecificationException>(() => repo.CreateBranch(name, "0266163"));
}
}

Expand Down
10 changes: 8 additions & 2 deletions LibGit2Sharp.Tests/FetchFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,18 @@ public void CanFetchAllTagsIntoAnEmptyRepository(string url)
TestRemoteInfo remoteInfo = TestRemoteInfo.TestRemoteInstance;
var expectedFetchState = new ExpectedFetchState(remoteName);

// Add expected tags only as no branches are expected to be fetched
// Add expected tags
foreach (KeyValuePair<string, TestRemoteInfo.ExpectedTagInfo> kvp in remoteInfo.Tags)
{
expectedFetchState.AddExpectedTag(kvp.Key, ObjectId.Zero, kvp.Value);
}

// Add expected branch objects
foreach (KeyValuePair<string, ObjectId> kvp in remoteInfo.BranchTips)
{
expectedFetchState.AddExpectedBranch(kvp.Key, ObjectId.Zero, kvp.Value);
}

// Perform the actual fetch
repo.Network.Fetch(remote, new FetchOptions {
TagFetchMode = TagFetchMode.All,
Expand All @@ -96,7 +102,7 @@ public void CanFetchAllTagsIntoAnEmptyRepository(string url)
expectedFetchState.CheckUpdatedReferences(repo);

// Verify the reflog entries
Assert.Equal(0, repo.Refs.Log(string.Format("refs/remotes/{0}/master", remoteName)).Count()); // Only tags are retrieved
Assert.Equal(1, repo.Refs.Log(string.Format("refs/remotes/{0}/master", remoteName)).Count()); // Branches are also retrieved
}
}

Expand Down
2 changes: 1 addition & 1 deletion LibGit2Sharp.Tests/ResetHeadFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void ResettingWithBadParamsThrows()
Assert.Throws<ArgumentNullException>(() => repo.Reset(ResetMode.Soft, (Commit)null));
Assert.Throws<ArgumentException>(() => repo.Reset(ResetMode.Soft, ""));
Assert.Throws<LibGit2SharpException>(() => repo.Reset(ResetMode.Soft, Constants.UnknownSha));
Assert.Throws<LibGit2SharpException>(() => repo.Reset(ResetMode.Soft, repo.Head.Tip.Tree.Sha));
Assert.Throws<InvalidSpecificationException>(() => repo.Reset(ResetMode.Soft, repo.Head.Tip.Tree.Sha));
}
}

Expand Down
15 changes: 0 additions & 15 deletions LibGit2Sharp.Tests/StatusFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -401,21 +401,6 @@ public void RetrievingTheStatusOfTheRepositoryHonorsTheGitIgnoreDirectives()
}
}

[Fact]
public void RetrievingTheStatusOfAnAmbiguousFileThrows()
{
string path = CloneStandardTestRepo();
using (var repo = new Repository(path))
{
Touch(repo.Info.WorkingDirectory, "1/ambiguous1.txt", "I don't like brackets.");

string relativePath = Path.Combine("1", "ambiguous[1].txt");
Touch(repo.Info.WorkingDirectory, relativePath, "Brackets all the way.");

Assert.Throws<AmbiguousSpecificationException>(() => repo.RetrieveStatus(relativePath));
}
}

[Theory]
[InlineData(true, FileStatus.Unaltered, FileStatus.Unaltered)]
[InlineData(false, FileStatus.Missing, FileStatus.Untracked)]
Expand Down
20 changes: 20 additions & 0 deletions LibGit2Sharp/Core/GitErrorCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,26 @@ internal enum GitErrorCode
/// </summary>
Modified = -15,

/// <summary>
/// Authentication error.
/// </summary>
Auth = -16,

/// <summary>
/// Server certificate is invalid.
/// </summary>
Certificate = -17,

/// <summary>
/// Patch/merge has already been applied.
/// </summary>
Applied = -18,

/// <summary>
/// The requested peel operation is not possible.
/// </summary>
Peel = -19,

/// <summary>
/// Skip and passthrough the given ODB backend.
/// </summary>
Expand Down
6 changes: 6 additions & 0 deletions LibGit2Sharp/Core/GitRemoteCallbacks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ internal struct GitRemoteCallbacks

internal NativeMethods.remote_update_tips_callback update_tips;

internal NativeMethods.git_packbuilder_progress pack_progress;

internal NativeMethods.git_push_transfer_progress push_transfer_progress;

internal IntPtr push_update_reference;

internal IntPtr payload;
}
}
2 changes: 1 addition & 1 deletion LibGit2Sharp/Core/NativeDllName.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ namespace LibGit2Sharp.Core
{
internal static class NativeDllName
{
public const string Name = "git2-3f8d005";
public const string Name = "git2-4eb97ef";
}
}
24 changes: 15 additions & 9 deletions LibGit2Sharp/Core/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ private sealed class LibraryLifetimeObject : CriticalFinalizerObject
[MethodImpl(MethodImplOptions.NoInlining)]
public LibraryLifetimeObject()
{
Ensure.ZeroResult(git_threads_init());
int res = git_libgit2_init();
Ensure.Int32Result(res);
if (res == 1)
{
// Ignore the error that this propagates. Call it in case openssl is being used.
git_openssl_set_locking();
}
AddHandle();
}

Expand All @@ -52,7 +58,7 @@ internal static void RemoveHandle()
int count = Interlocked.Decrement(ref handlesCount);
if (count == 0)
{
git_threads_shutdown();
git_libgit2_shutdown();
}
}

Expand Down Expand Up @@ -680,9 +686,9 @@ internal static extern int git_message_prettify(
internal static extern int git_note_create(
out GitOid noteOid,
RepositorySafeHandle repo,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string notes_ref,
SignatureSafeHandle author,
SignatureSafeHandle committer,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string notes_ref,
ref GitOid oid,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string note,
int force);
Expand Down Expand Up @@ -845,9 +851,6 @@ internal delegate int push_status_foreach_cb(
IntPtr msg,
IntPtr data);

[DllImport(libgit2)]
internal static extern int git_push_unpack_ok(PushSafeHandle push);

[DllImport(libgit2)]
internal static extern int git_push_update_tips(
PushSafeHandle push,
Expand Down Expand Up @@ -1090,7 +1093,7 @@ internal static extern int git_remote_is_valid_name(
internal static extern int git_remote_list(out GitStrArray array, RepositorySafeHandle repo);

[DllImport(libgit2)]
internal static extern int git_remote_load(
internal static extern int git_remote_lookup(
out RemoteSafeHandle remote,
RepositorySafeHandle repo,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string name);
Expand Down Expand Up @@ -1490,10 +1493,13 @@ internal static extern int git_tag_delete(
internal static extern GitObjectType git_tag_target_type(GitObjectSafeHandle tag);

[DllImport(libgit2)]
internal static extern int git_threads_init();
internal static extern int git_libgit2_init();

[DllImport(libgit2)]
internal static extern int git_libgit2_shutdown();

[DllImport(libgit2)]
internal static extern void git_threads_shutdown();
internal static extern int git_openssl_set_locking();

internal delegate void git_trace_cb(LogLevel level, IntPtr message);

Expand Down
16 changes: 5 additions & 11 deletions LibGit2Sharp/Core/Proxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1171,9 +1171,9 @@ public static string git_message_prettify(string message, char? commentChar)

public static ObjectId git_note_create(
RepositorySafeHandle repo,
string notes_ref,
Signature author,
Signature committer,
string notes_ref,
ObjectId targetId,
string note,
bool force)
Expand All @@ -1185,7 +1185,7 @@ public static ObjectId git_note_create(
GitOid noteOid;
GitOid oid = targetId.Oid;

int res = NativeMethods.git_note_create(out noteOid, repo, authorHandle, committerHandle, notes_ref, ref oid, note, force ? 1 : 0);
int res = NativeMethods.git_note_create(out noteOid, repo, notes_ref, authorHandle, committerHandle, ref oid, note, force ? 1 : 0);
Ensure.ZeroResult(res);

return noteOid;
Expand Down Expand Up @@ -1313,7 +1313,7 @@ public static GitObjectSafeHandle git_object_peel(RepositorySafeHandle repo, Obj
}

if (!throwsIfCanNotPeel &&
(res == (int)GitErrorCode.NotFound || res == (int)GitErrorCode.Ambiguous))
(res == (int)GitErrorCode.NotFound || res == (int)GitErrorCode.Ambiguous || res == (int)GitErrorCode.InvalidSpecification || res == (int)GitErrorCode.Peel))
{
return null;
}
Expand Down Expand Up @@ -1564,12 +1564,6 @@ public static void git_push_status_foreach(PushSafeHandle push, NativeMethods.pu
}
}

public static bool git_push_unpack_ok(PushSafeHandle push)
{
int res = NativeMethods.git_push_unpack_ok(push);
return res == 1;
}

public static void git_push_update_tips(PushSafeHandle push, Signature signature, string logMessage)
{
using (ThreadAffinity())
Expand Down Expand Up @@ -2117,12 +2111,12 @@ public static IEnumerable<DirectReference> git_remote_ls(Repository repository,
return refs;
}

public static RemoteSafeHandle git_remote_load(RepositorySafeHandle repo, string name, bool throwsIfNotFound)
public static RemoteSafeHandle git_remote_lookup(RepositorySafeHandle repo, string name, bool throwsIfNotFound)
{
using (ThreadAffinity())
{
RemoteSafeHandle handle;
int res = NativeMethods.git_remote_load(out handle, repo, name);
int res = NativeMethods.git_remote_lookup(out handle, repo, name);

if (res == (int)GitErrorCode.NotFound && !throwsIfNotFound)
{
Expand Down
14 changes: 4 additions & 10 deletions LibGit2Sharp/Network.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public virtual IEnumerable<DirectReference> ListReferences(Remote remote, Creden
{
Ensure.ArgumentNotNull(remote, "remote");

using (RemoteSafeHandle remoteHandle = Proxy.git_remote_load(repository.Handle, remote.Name, true))
using (RemoteSafeHandle remoteHandle = Proxy.git_remote_lookup(repository.Handle, remote.Name, true))
{
if (credentialsProvider != null)
{
Expand Down Expand Up @@ -129,7 +129,7 @@ public virtual void Fetch(Remote remote, FetchOptions options = null,
{
Ensure.ArgumentNotNull(remote, "remote");

using (RemoteSafeHandle remoteHandle = Proxy.git_remote_load(repository.Handle, remote.Name, true))
using (RemoteSafeHandle remoteHandle = Proxy.git_remote_lookup(repository.Handle, remote.Name, true))
{
DoFetch(remoteHandle, options, signature.OrDefault(repository.Config), logMessage);
}
Expand All @@ -150,7 +150,7 @@ public virtual void Fetch(Remote remote, IEnumerable<string> refspecs, FetchOpti
Ensure.ArgumentNotNull(remote, "remote");
Ensure.ArgumentNotNull(refspecs, "refspecs");

using (RemoteSafeHandle remoteHandle = Proxy.git_remote_load(repository.Handle, remote.Name, true))
using (RemoteSafeHandle remoteHandle = Proxy.git_remote_lookup(repository.Handle, remote.Name, true))
{
Proxy.git_remote_set_fetch_refspecs(remoteHandle, refspecs);

Expand Down Expand Up @@ -270,7 +270,7 @@ public virtual void Push(
PushCallbacks pushStatusUpdates = new PushCallbacks(pushOptions.OnPushStatusError);

// Load the remote.
using (RemoteSafeHandle remoteHandle = Proxy.git_remote_load(repository.Handle, remote.Name, true))
using (RemoteSafeHandle remoteHandle = Proxy.git_remote_lookup(repository.Handle, remote.Name, true))
{
var callbacks = new RemoteCallbacks(pushOptions.CredentialsProvider);
GitRemoteCallbacks gitCallbacks = callbacks.GenerateCallbacks();
Expand Down Expand Up @@ -305,12 +305,6 @@ public virtual void Push(
}

Proxy.git_push_finish(pushHandle);

if (!Proxy.git_push_unpack_ok(pushHandle))
{
throw new LibGit2SharpException("Push failed - remote did not successfully unpack.");
}

Proxy.git_push_status_foreach(pushHandle, pushStatusUpdates.Callback);
Proxy.git_push_update_tips(pushHandle, signature.OrDefault(repository.Config), logMessage);
}
Expand Down
2 changes: 1 addition & 1 deletion LibGit2Sharp/NoteCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public virtual Note Add(ObjectId targetId, string message, Signature author, Sig

Remove(targetId, author, committer, @namespace);

Proxy.git_note_create(repo.Handle, author, committer, canonicalNamespace, targetId, message, true);
Proxy.git_note_create(repo.Handle, canonicalNamespace, author, committer, targetId, message, true);

return this[canonicalNamespace, targetId];
}
Expand Down
2 changes: 1 addition & 1 deletion LibGit2Sharp/Remote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public virtual IEnumerable<RefSpec> PushRefSpecs
/// <returns>The transformed reference.</returns>
internal string FetchSpecTransformToSource(string reference)
{
using (RemoteSafeHandle remoteHandle = Proxy.git_remote_load(repository.Handle, Name, true))
using (RemoteSafeHandle remoteHandle = Proxy.git_remote_lookup(repository.Handle, Name, true))
{
GitRefSpecHandle fetchSpecPtr = Proxy.git_remote_get_refspec(remoteHandle, 0);
return Proxy.git_refspec_rtransform(fetchSpecPtr, reference);
Expand Down
2 changes: 1 addition & 1 deletion LibGit2Sharp/RemoteCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ internal Remote RemoteForName(string name, bool shouldThrowIfNotFound = true)
{
Ensure.ArgumentNotNull(name, "name");

using (RemoteSafeHandle handle = Proxy.git_remote_load(repository.Handle, name, shouldThrowIfNotFound))
using (RemoteSafeHandle handle = Proxy.git_remote_lookup(repository.Handle, name, shouldThrowIfNotFound))
{
return handle == null ? null : Remote.BuildFromPtr(handle, this.repository);
}
Expand Down
2 changes: 1 addition & 1 deletion LibGit2Sharp/RemoteUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ internal RemoteUpdater(Repository repo, Remote remote)
fetchRefSpecs = new UpdatingCollection<string>(GetFetchRefSpecs, SetFetchRefSpecs);
pushRefSpecs = new UpdatingCollection<string>(GetPushRefSpecs, SetPushRefSpecs);

remoteHandle = Proxy.git_remote_load(repo.Handle, remote.Name, true);
remoteHandle = Proxy.git_remote_lookup(repo.Handle, remote.Name, true);
}

private IEnumerable<string> GetFetchRefSpecs()
Expand Down
2 changes: 1 addition & 1 deletion LibGit2Sharp/libgit2_hash.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3f8d005a82b39c504220d65b6a6aa696c3b1a9c4
4eb97ef3bf18403fbce351ae4cac673655d2886a
2 changes: 1 addition & 1 deletion libgit2
Submodule libgit2 updated 160 files
16 changes: 8 additions & 8 deletions nuget.package/build/LibGit2Sharp.props
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)\..\..\lib\net40\NativeBinaries\amd64\git2-3f8d005.dll">
<Link>NativeBinaries\amd64\git2-3f8d005.dll</Link>
<None Include="$(MSBuildThisFileDirectory)\..\..\lib\net40\NativeBinaries\amd64\git2-4eb97ef.dll">
<Link>NativeBinaries\amd64\git2-4eb97ef.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)\..\..\lib\net40\NativeBinaries\amd64\git2-3f8d005.pdb">
<Link>NativeBinaries\amd64\git2-3f8d005.pdb</Link>
<None Include="$(MSBuildThisFileDirectory)\..\..\lib\net40\NativeBinaries\amd64\git2-4eb97ef.pdb">
<Link>NativeBinaries\amd64\git2-4eb97ef.pdb</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)\..\..\lib\net40\NativeBinaries\x86\git2-3f8d005.dll">
<Link>NativeBinaries\x86\git2-3f8d005.dll</Link>
<None Include="$(MSBuildThisFileDirectory)\..\..\lib\net40\NativeBinaries\x86\git2-4eb97ef.dll">
<Link>NativeBinaries\x86\git2-4eb97ef.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)\..\..\lib\net40\NativeBinaries\x86\git2-3f8d005.pdb">
<Link>NativeBinaries\x86\git2-3f8d005.pdb</Link>
<None Include="$(MSBuildThisFileDirectory)\..\..\lib\net40\NativeBinaries\x86\git2-4eb97ef.pdb">
<Link>NativeBinaries\x86\git2-4eb97ef.pdb</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
Expand Down