Skip to content

Commit 8c48d39

Browse files
TherzokEdward Thomson
authored and
Edward Thomson
committed
Update libgit2 to 4eb97ef
libgit2/libgit2@3f8d005...4eb97ef
1 parent 090c6e9 commit 8c48d39

23 files changed

+77
-66
lines changed
-963 KB
Binary file not shown.
968 KB
Binary file not shown.
-730 KB
Binary file not shown.
733 KB
Binary file not shown.

LibGit2Sharp.Tests/BranchFixture.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,9 @@ public void CreatingABranchFromANonCommitObjectThrows()
241241
using (var repo = new Repository(BareTestRepoPath))
242242
{
243243
const string name = "sorry-dude-i-do-not-do-blobs-nor-trees";
244-
Assert.Throws<LibGit2SharpException>(() => repo.CreateBranch(name, "refs/tags/point_to_blob"));
245-
Assert.Throws<LibGit2SharpException>(() => repo.CreateBranch(name, "53fc32d"));
246-
Assert.Throws<LibGit2SharpException>(() => repo.CreateBranch(name, "0266163"));
244+
Assert.Throws<InvalidSpecificationException>(() => repo.CreateBranch(name, "refs/tags/point_to_blob"));
245+
Assert.Throws<InvalidSpecificationException>(() => repo.CreateBranch(name, "53fc32d"));
246+
Assert.Throws<InvalidSpecificationException>(() => repo.CreateBranch(name, "0266163"));
247247
}
248248
}
249249

LibGit2Sharp.Tests/FetchFixture.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,18 @@ public void CanFetchAllTagsIntoAnEmptyRepository(string url)
8080
TestRemoteInfo remoteInfo = TestRemoteInfo.TestRemoteInstance;
8181
var expectedFetchState = new ExpectedFetchState(remoteName);
8282

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

89+
// Add expected branch objects
90+
foreach (KeyValuePair<string, ObjectId> kvp in remoteInfo.BranchTips)
91+
{
92+
expectedFetchState.AddExpectedBranch(kvp.Key, ObjectId.Zero, kvp.Value);
93+
}
94+
8995
// Perform the actual fetch
9096
repo.Network.Fetch(remote, new FetchOptions {
9197
TagFetchMode = TagFetchMode.All,
@@ -96,7 +102,7 @@ public void CanFetchAllTagsIntoAnEmptyRepository(string url)
96102
expectedFetchState.CheckUpdatedReferences(repo);
97103

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

LibGit2Sharp.Tests/ResetHeadFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public void ResettingWithBadParamsThrows()
7171
Assert.Throws<ArgumentNullException>(() => repo.Reset(ResetMode.Soft, (Commit)null));
7272
Assert.Throws<ArgumentException>(() => repo.Reset(ResetMode.Soft, ""));
7373
Assert.Throws<LibGit2SharpException>(() => repo.Reset(ResetMode.Soft, Constants.UnknownSha));
74-
Assert.Throws<LibGit2SharpException>(() => repo.Reset(ResetMode.Soft, repo.Head.Tip.Tree.Sha));
74+
Assert.Throws<InvalidSpecificationException>(() => repo.Reset(ResetMode.Soft, repo.Head.Tip.Tree.Sha));
7575
}
7676
}
7777

LibGit2Sharp.Tests/StatusFixture.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -401,21 +401,6 @@ public void RetrievingTheStatusOfTheRepositoryHonorsTheGitIgnoreDirectives()
401401
}
402402
}
403403

404-
[Fact]
405-
public void RetrievingTheStatusOfAnAmbiguousFileThrows()
406-
{
407-
string path = CloneStandardTestRepo();
408-
using (var repo = new Repository(path))
409-
{
410-
Touch(repo.Info.WorkingDirectory, "1/ambiguous1.txt", "I don't like brackets.");
411-
412-
string relativePath = Path.Combine("1", "ambiguous[1].txt");
413-
Touch(repo.Info.WorkingDirectory, relativePath, "Brackets all the way.");
414-
415-
Assert.Throws<AmbiguousSpecificationException>(() => repo.RetrieveStatus(relativePath));
416-
}
417-
}
418-
419404
[Theory]
420405
[InlineData(true, FileStatus.Unaltered, FileStatus.Unaltered)]
421406
[InlineData(false, FileStatus.Missing, FileStatus.Untracked)]

LibGit2Sharp/Core/GitErrorCode.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,26 @@ internal enum GitErrorCode
7070
/// </summary>
7171
Modified = -15,
7272

73+
/// <summary>
74+
/// Authentication error.
75+
/// </summary>
76+
Auth = -16,
77+
78+
/// <summary>
79+
/// Server certificate is invalid.
80+
/// </summary>
81+
Certificate = -17,
82+
83+
/// <summary>
84+
/// Patch/merge has already been applied.
85+
/// </summary>
86+
Applied = -18,
87+
88+
/// <summary>
89+
/// The requested peel operation is not possible.
90+
/// </summary>
91+
Peel = -19,
92+
7393
/// <summary>
7494
/// Skip and passthrough the given ODB backend.
7595
/// </summary>

LibGit2Sharp/Core/GitRemoteCallbacks.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ internal struct GitRemoteCallbacks
2323

2424
internal NativeMethods.remote_update_tips_callback update_tips;
2525

26+
internal NativeMethods.git_packbuilder_progress pack_progress;
27+
28+
internal NativeMethods.git_push_transfer_progress push_transfer_progress;
29+
30+
internal IntPtr push_update_reference;
31+
2632
internal IntPtr payload;
2733
}
2834
}

LibGit2Sharp/Core/NativeDllName.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ namespace LibGit2Sharp.Core
22
{
33
internal static class NativeDllName
44
{
5-
public const string Name = "git2-3f8d005";
5+
public const string Name = "git2-4eb97ef";
66
}
77
}

LibGit2Sharp/Core/NativeMethods.cs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ private sealed class LibraryLifetimeObject : CriticalFinalizerObject
3030
[MethodImpl(MethodImplOptions.NoInlining)]
3131
public LibraryLifetimeObject()
3232
{
33-
Ensure.ZeroResult(git_threads_init());
33+
int res = git_libgit2_init();
34+
Ensure.Int32Result(res);
35+
if (res == 1)
36+
{
37+
// Ignore the error that this propagates. Call it in case openssl is being used.
38+
git_openssl_set_locking();
39+
}
3440
AddHandle();
3541
}
3642

@@ -52,7 +58,7 @@ internal static void RemoveHandle()
5258
int count = Interlocked.Decrement(ref handlesCount);
5359
if (count == 0)
5460
{
55-
git_threads_shutdown();
61+
git_libgit2_shutdown();
5662
}
5763
}
5864

@@ -680,9 +686,9 @@ internal static extern int git_message_prettify(
680686
internal static extern int git_note_create(
681687
out GitOid noteOid,
682688
RepositorySafeHandle repo,
689+
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string notes_ref,
683690
SignatureSafeHandle author,
684691
SignatureSafeHandle committer,
685-
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string notes_ref,
686692
ref GitOid oid,
687693
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string note,
688694
int force);
@@ -845,9 +851,6 @@ internal delegate int push_status_foreach_cb(
845851
IntPtr msg,
846852
IntPtr data);
847853

848-
[DllImport(libgit2)]
849-
internal static extern int git_push_unpack_ok(PushSafeHandle push);
850-
851854
[DllImport(libgit2)]
852855
internal static extern int git_push_update_tips(
853856
PushSafeHandle push,
@@ -1090,7 +1093,7 @@ internal static extern int git_remote_is_valid_name(
10901093
internal static extern int git_remote_list(out GitStrArray array, RepositorySafeHandle repo);
10911094

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

14921495
[DllImport(libgit2)]
1493-
internal static extern int git_threads_init();
1496+
internal static extern int git_libgit2_init();
1497+
1498+
[DllImport(libgit2)]
1499+
internal static extern int git_libgit2_shutdown();
14941500

14951501
[DllImport(libgit2)]
1496-
internal static extern void git_threads_shutdown();
1502+
internal static extern int git_openssl_set_locking();
14971503

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

LibGit2Sharp/Core/Proxy.cs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,9 +1171,9 @@ public static string git_message_prettify(string message, char? commentChar)
11711171

11721172
public static ObjectId git_note_create(
11731173
RepositorySafeHandle repo,
1174+
string notes_ref,
11741175
Signature author,
11751176
Signature committer,
1176-
string notes_ref,
11771177
ObjectId targetId,
11781178
string note,
11791179
bool force)
@@ -1185,7 +1185,7 @@ public static ObjectId git_note_create(
11851185
GitOid noteOid;
11861186
GitOid oid = targetId.Oid;
11871187

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

11911191
return noteOid;
@@ -1313,7 +1313,7 @@ public static GitObjectSafeHandle git_object_peel(RepositorySafeHandle repo, Obj
13131313
}
13141314

13151315
if (!throwsIfCanNotPeel &&
1316-
(res == (int)GitErrorCode.NotFound || res == (int)GitErrorCode.Ambiguous))
1316+
(res == (int)GitErrorCode.NotFound || res == (int)GitErrorCode.Ambiguous || res == (int)GitErrorCode.InvalidSpecification || res == (int)GitErrorCode.Peel))
13171317
{
13181318
return null;
13191319
}
@@ -1564,12 +1564,6 @@ public static void git_push_status_foreach(PushSafeHandle push, NativeMethods.pu
15641564
}
15651565
}
15661566

1567-
public static bool git_push_unpack_ok(PushSafeHandle push)
1568-
{
1569-
int res = NativeMethods.git_push_unpack_ok(push);
1570-
return res == 1;
1571-
}
1572-
15731567
public static void git_push_update_tips(PushSafeHandle push, Signature signature, string logMessage)
15741568
{
15751569
using (ThreadAffinity())
@@ -2117,12 +2111,12 @@ public static IEnumerable<DirectReference> git_remote_ls(Repository repository,
21172111
return refs;
21182112
}
21192113

2120-
public static RemoteSafeHandle git_remote_load(RepositorySafeHandle repo, string name, bool throwsIfNotFound)
2114+
public static RemoteSafeHandle git_remote_lookup(RepositorySafeHandle repo, string name, bool throwsIfNotFound)
21212115
{
21222116
using (ThreadAffinity())
21232117
{
21242118
RemoteSafeHandle handle;
2125-
int res = NativeMethods.git_remote_load(out handle, repo, name);
2119+
int res = NativeMethods.git_remote_lookup(out handle, repo, name);
21262120

21272121
if (res == (int)GitErrorCode.NotFound && !throwsIfNotFound)
21282122
{

LibGit2Sharp/Network.cs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public virtual IEnumerable<DirectReference> ListReferences(Remote remote, Creden
5252
{
5353
Ensure.ArgumentNotNull(remote, "remote");
5454

55-
using (RemoteSafeHandle remoteHandle = Proxy.git_remote_load(repository.Handle, remote.Name, true))
55+
using (RemoteSafeHandle remoteHandle = Proxy.git_remote_lookup(repository.Handle, remote.Name, true))
5656
{
5757
if (credentialsProvider != null)
5858
{
@@ -129,7 +129,7 @@ public virtual void Fetch(Remote remote, FetchOptions options = null,
129129
{
130130
Ensure.ArgumentNotNull(remote, "remote");
131131

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

153-
using (RemoteSafeHandle remoteHandle = Proxy.git_remote_load(repository.Handle, remote.Name, true))
153+
using (RemoteSafeHandle remoteHandle = Proxy.git_remote_lookup(repository.Handle, remote.Name, true))
154154
{
155155
Proxy.git_remote_set_fetch_refspecs(remoteHandle, refspecs);
156156

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

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

307307
Proxy.git_push_finish(pushHandle);
308-
309-
if (!Proxy.git_push_unpack_ok(pushHandle))
310-
{
311-
throw new LibGit2SharpException("Push failed - remote did not successfully unpack.");
312-
}
313-
314308
Proxy.git_push_status_foreach(pushHandle, pushStatusUpdates.Callback);
315309
Proxy.git_push_update_tips(pushHandle, signature.OrDefault(repository.Config), logMessage);
316310
}

LibGit2Sharp/NoteCollection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public virtual Note Add(ObjectId targetId, string message, Signature author, Sig
186186

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

189-
Proxy.git_note_create(repo.Handle, author, committer, canonicalNamespace, targetId, message, true);
189+
Proxy.git_note_create(repo.Handle, canonicalNamespace, author, committer, targetId, message, true);
190190

191191
return this[canonicalNamespace, targetId];
192192
}

LibGit2Sharp/Remote.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public virtual IEnumerable<RefSpec> PushRefSpecs
8888
/// <returns>The transformed reference.</returns>
8989
internal string FetchSpecTransformToSource(string reference)
9090
{
91-
using (RemoteSafeHandle remoteHandle = Proxy.git_remote_load(repository.Handle, Name, true))
91+
using (RemoteSafeHandle remoteHandle = Proxy.git_remote_lookup(repository.Handle, Name, true))
9292
{
9393
GitRefSpecHandle fetchSpecPtr = Proxy.git_remote_get_refspec(remoteHandle, 0);
9494
return Proxy.git_refspec_rtransform(fetchSpecPtr, reference);

LibGit2Sharp/RemoteCollection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ internal Remote RemoteForName(string name, bool shouldThrowIfNotFound = true)
4343
{
4444
Ensure.ArgumentNotNull(name, "name");
4545

46-
using (RemoteSafeHandle handle = Proxy.git_remote_load(repository.Handle, name, shouldThrowIfNotFound))
46+
using (RemoteSafeHandle handle = Proxy.git_remote_lookup(repository.Handle, name, shouldThrowIfNotFound))
4747
{
4848
return handle == null ? null : Remote.BuildFromPtr(handle, this.repository);
4949
}

LibGit2Sharp/RemoteUpdater.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ internal RemoteUpdater(Repository repo, Remote remote)
2828
fetchRefSpecs = new UpdatingCollection<string>(GetFetchRefSpecs, SetFetchRefSpecs);
2929
pushRefSpecs = new UpdatingCollection<string>(GetPushRefSpecs, SetPushRefSpecs);
3030

31-
remoteHandle = Proxy.git_remote_load(repo.Handle, remote.Name, true);
31+
remoteHandle = Proxy.git_remote_lookup(repo.Handle, remote.Name, true);
3232
}
3333

3434
private IEnumerable<string> GetFetchRefSpecs()

LibGit2Sharp/libgit2_hash.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3f8d005a82b39c504220d65b6a6aa696c3b1a9c4
1+
4eb97ef3bf18403fbce351ae4cac673655d2886a

libgit2

Submodule libgit2 updated 160 files

nuget.package/build/LibGit2Sharp.props

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<ItemGroup>
4-
<None Include="$(MSBuildThisFileDirectory)\..\..\lib\net40\NativeBinaries\amd64\git2-3f8d005.dll">
5-
<Link>NativeBinaries\amd64\git2-3f8d005.dll</Link>
4+
<None Include="$(MSBuildThisFileDirectory)\..\..\lib\net40\NativeBinaries\amd64\git2-4eb97ef.dll">
5+
<Link>NativeBinaries\amd64\git2-4eb97ef.dll</Link>
66
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
77
</None>
8-
<None Include="$(MSBuildThisFileDirectory)\..\..\lib\net40\NativeBinaries\amd64\git2-3f8d005.pdb">
9-
<Link>NativeBinaries\amd64\git2-3f8d005.pdb</Link>
8+
<None Include="$(MSBuildThisFileDirectory)\..\..\lib\net40\NativeBinaries\amd64\git2-4eb97ef.pdb">
9+
<Link>NativeBinaries\amd64\git2-4eb97ef.pdb</Link>
1010
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
1111
</None>
12-
<None Include="$(MSBuildThisFileDirectory)\..\..\lib\net40\NativeBinaries\x86\git2-3f8d005.dll">
13-
<Link>NativeBinaries\x86\git2-3f8d005.dll</Link>
12+
<None Include="$(MSBuildThisFileDirectory)\..\..\lib\net40\NativeBinaries\x86\git2-4eb97ef.dll">
13+
<Link>NativeBinaries\x86\git2-4eb97ef.dll</Link>
1414
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
1515
</None>
16-
<None Include="$(MSBuildThisFileDirectory)\..\..\lib\net40\NativeBinaries\x86\git2-3f8d005.pdb">
17-
<Link>NativeBinaries\x86\git2-3f8d005.pdb</Link>
16+
<None Include="$(MSBuildThisFileDirectory)\..\..\lib\net40\NativeBinaries\x86\git2-4eb97ef.pdb">
17+
<Link>NativeBinaries\x86\git2-4eb97ef.pdb</Link>
1818
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
1919
</None>
2020
</ItemGroup>

0 commit comments

Comments
 (0)