Skip to content

Commit 40ac869

Browse files
committed
Update libgit2 binaries to 58eea5e
libgit2/libgit2@06d772d...58eea5e Configuration: Use snapshot for Get/Find calls. Thanks @carlosmn. Merge: Keep track of new MergePreference. StatusFixture: change expectations for star-ignore When passing bin/* newer libgit2 considers that as ignoreing the bin/ directory and thus won't give us its contents unless we pass in the RecurseIgnoredDirs option. Done by @carlosmn.
1 parent 3c3035d commit 40ac869

24 files changed

+110
-23
lines changed
-887 KB
Binary file not shown.
-4.6 MB
Binary file not shown.
920 KB
Binary file not shown.
5.23 MB
Binary file not shown.
-684 KB
Binary file not shown.
-4.57 MB
Binary file not shown.
702 KB
Binary file not shown.
5.23 MB
Binary file not shown.

LibGit2Sharp.Tests/StatusFixture.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,12 @@ public void RetrievingTheStatusOfTheRepositoryHonorsTheGitIgnoreDirectivesThroug
495495
Assert.Equal(FileStatus.Ignored, repo.Index.RetrieveStatus("bin/look-ma.txt"));
496496
Assert.Equal(FileStatus.Untracked, repo.Index.RetrieveStatus("bin/what-about-me.txt"));
497497

498+
// bin/* is considered as ignoring the dir itself
498499
newStatus = repo.Index.RetrieveStatus();
500+
Assert.Equal(new[] { "bin" + dirSep }, newStatus.Ignored.Select(s => s.FilePath));
499501

502+
// if we recurse into ignored dirs, then we get the actual list
503+
newStatus = repo.Index.RetrieveStatus(new StatusOptions { RecurseIgnoredDirs = true });
500504
Assert.Equal(new[] { "bin" + dirSep + "look-ma.txt" }, newStatus.Ignored.Select(s => s.FilePath));
501505
Assert.True(newStatus.Untracked.Select(s => s.FilePath).Contains("bin" + dirSep + "what-about-me.txt"));
502506
}

LibGit2Sharp/BranchCollection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ private Branch BuildFromReferenceName(string canonicalName)
9191
/// <returns>An <see cref="IEnumerator{T}"/> object that can be used to iterate through the collection.</returns>
9292
public virtual IEnumerator<Branch> GetEnumerator()
9393
{
94-
return Proxy.git_branch_iterator(repo, GitBranchType.GIT_BRANCH_LOCAL | GitBranchType.GIT_BRANCH_REMOTE)
94+
return Proxy.git_branch_iterator(repo, GitBranchType.GIT_BRANCH_ALL)
9595
.ToList().GetEnumerator();
9696
}
9797

LibGit2Sharp/Configuration.cs

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ public Configuration(string globalConfigurationFileLocation = null, string xdgCo
8888
/// </summary>
8989
public virtual bool HasConfig(ConfigurationLevel level)
9090
{
91-
using (ConfigurationSafeHandle handle = RetrieveConfigurationHandle(level, false))
91+
using (ConfigurationSafeHandle snapshot = Snapshot ())
92+
using (ConfigurationSafeHandle handle = RetrieveConfigurationHandle(level, false, snapshot))
9293
{
9394
return handle != null;
9495
}
@@ -117,7 +118,7 @@ public virtual void Unset(string key, ConfigurationLevel level = ConfigurationLe
117118
{
118119
Ensure.ArgumentNotNullOrEmptyString(key, "key");
119120

120-
using (ConfigurationSafeHandle h = RetrieveConfigurationHandle(level, true))
121+
using (ConfigurationSafeHandle h = RetrieveConfigurationHandle(level, true, configHandle))
121122
{
122123
Proxy.git_config_delete(h, key);
123124
}
@@ -164,7 +165,10 @@ public virtual ConfigurationEntry<T> Get<T>(string key)
164165
{
165166
Ensure.ArgumentNotNullOrEmptyString(key, "key");
166167

167-
return Proxy.git_config_get_entry<T>(configHandle, key);
168+
using (ConfigurationSafeHandle snapshot = Snapshot())
169+
{
170+
return Proxy.git_config_get_entry<T>(snapshot, key);
171+
}
168172
}
169173

170174
/// <summary>
@@ -192,7 +196,8 @@ public virtual ConfigurationEntry<T> Get<T>(string key, ConfigurationLevel level
192196
{
193197
Ensure.ArgumentNotNullOrEmptyString(key, "key");
194198

195-
using (ConfigurationSafeHandle handle = RetrieveConfigurationHandle(level, false))
199+
using (ConfigurationSafeHandle snapshot = Snapshot())
200+
using (ConfigurationSafeHandle handle = RetrieveConfigurationHandle(level, false, snapshot))
196201
{
197202
if (handle == null)
198203
{
@@ -224,7 +229,7 @@ public virtual void Set<T>(string key, T value, ConfigurationLevel level = Confi
224229
{
225230
Ensure.ArgumentNotNullOrEmptyString(key, "key");
226231

227-
using (ConfigurationSafeHandle h = RetrieveConfigurationHandle(level, true))
232+
using (ConfigurationSafeHandle h = RetrieveConfigurationHandle(level, true, configHandle))
228233
{
229234
if (!configurationTypedUpdater.ContainsKey(typeof(T)))
230235
{
@@ -246,18 +251,19 @@ public virtual IEnumerable<ConfigurationEntry<string>> Find(string regexp,
246251
{
247252
Ensure.ArgumentNotNullOrEmptyString(regexp, "regexp");
248253

249-
using (ConfigurationSafeHandle h = RetrieveConfigurationHandle(level, true))
254+
using (ConfigurationSafeHandle snapshot = Snapshot())
255+
using (ConfigurationSafeHandle h = RetrieveConfigurationHandle(level, true, snapshot))
250256
{
251257
return Proxy.git_config_iterator_glob(h, regexp, BuildConfigEntry).ToList();
252258
}
253259
}
254260

255-
private ConfigurationSafeHandle RetrieveConfigurationHandle(ConfigurationLevel level, bool throwIfStoreHasNotBeenFound)
261+
private ConfigurationSafeHandle RetrieveConfigurationHandle(ConfigurationLevel level, bool throwIfStoreHasNotBeenFound, ConfigurationSafeHandle fromHandle)
256262
{
257263
ConfigurationSafeHandle handle = null;
258-
if (configHandle != null)
264+
if (fromHandle != null)
259265
{
260-
handle = Proxy.git_config_open_level(configHandle, level);
266+
handle = Proxy.git_config_open_level(fromHandle, level);
261267
}
262268

263269
if (handle == null && throwIfStoreHasNotBeenFound)
@@ -349,5 +355,10 @@ internal Signature BuildSignature(DateTimeOffset now, bool shouldThrowIfNotFound
349355
CultureInfo.InvariantCulture, "{0}@{1}", Environment.UserName, Environment.UserDomainName),
350356
now);
351357
}
358+
359+
private ConfigurationSafeHandle Snapshot()
360+
{
361+
return Proxy.git_config_snapshot(configHandle);
362+
}
352363
}
353364
}

LibGit2Sharp/Core/GitBranchType.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ internal enum GitBranchType
77
{
88
GIT_BRANCH_LOCAL = 1,
99
GIT_BRANCH_REMOTE = 2,
10+
GIT_BRANCH_ALL = GIT_BRANCH_LOCAL | GIT_BRANCH_REMOTE,
1011
}
1112
}

LibGit2Sharp/Core/GitCloneOptions.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33

44
namespace LibGit2Sharp.Core
55
{
6+
internal enum GitCloneLocal
7+
{
8+
CloneLocalAuto,
9+
CloneLocal,
10+
CloneNoLocal,
11+
CloneLocalNoLinks
12+
}
13+
614
[StructLayout(LayoutKind.Sequential)]
715
internal struct GitCloneOptions
816
{
@@ -13,6 +21,7 @@ internal struct GitCloneOptions
1321

1422
public int Bare;
1523
public int IgnoreCertErrors;
24+
public GitCloneLocal Local;
1625

1726
public IntPtr RemoteName;
1827
public IntPtr CheckoutBranch;

LibGit2Sharp/Core/GitCredentialType.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,10 @@ public enum GitCredentialType
2727
/// A key for NTLM/Kerberos "default" credentials.
2828
/// </summary>
2929
Default = (1 << 3),
30+
31+
/// <summary>
32+
/// TODO
33+
/// </summary>
34+
SshInteractive = (1 << 4),
3035
}
3136
}

LibGit2Sharp/Core/GitDiff.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,14 @@ internal enum GitDiffOptionFlags
104104
/// </summary>
105105
GIT_DIFF_ENABLE_FAST_UNTRACKED_DIRS = (1 << 14),
106106

107+
/// <summary>
108+
/// When diff finds a file in the working directory with stat
109+
/// information different from the index, but the OID ends up being the
110+
/// same, write the correct stat information into the index. Note:
111+
/// without this flag, diff will always leave the index untouched.
112+
/// </summary>
113+
GIT_DIFF_UPDATE_INDEX = (1 << 15),
114+
107115
/*
108116
* Options controlling how output will be generated
109117
*/
@@ -158,6 +166,12 @@ internal enum GitDiffOptionFlags
158166
/// Take extra time to find minimal diff
159167
/// </summary>
160168
GIT_DIFF_MINIMAL = (1 << 29),
169+
170+
/// <summary>
171+
/// Include the necessary deflate / delta information so that `git-apply`
172+
/// can apply given diff information to binary files.
173+
/// </summary>
174+
GIT_DIFF_SHOW_BINARY = (1 << 30),
161175
}
162176

163177
internal delegate int diff_notify_cb(

LibGit2Sharp/Core/GitMergeOpts.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,27 @@ internal enum GitMergeAnalysis
7171
GIT_MERGE_ANALYSIS_UNBORN = (1 << 3),
7272
}
7373

74+
internal enum GitMergePreference
75+
{
76+
/// <summary>
77+
/// No configuration was found that suggests a preferred behavior for
78+
/// merge.
79+
/// </summary>
80+
GIT_MERGE_PREFERENCE_NONE = 0,
81+
82+
/// <summary>
83+
/// There is a `merge.ff=false` configuration setting, suggesting that
84+
/// the user does not want to allow a fast-forward merge.
85+
/// </summary>
86+
GIT_MERGE_PREFERENCE_NO_FASTFORWARD = (1 << 0),
87+
88+
/// <summary>
89+
/// There is a `merge.ff=only` configuration setting, suggesting that
90+
/// the user only wants fast-forward merges.
91+
/// </summary>
92+
GIT_MERGE_PREFERENCE_FASTFORWARD_ONLY = (1 << 1),
93+
}
94+
7495
[Flags]
7596
internal enum GitMergeTreeFlags
7697
{

LibGit2Sharp/Core/GitRemoteHead.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ internal struct GitRemoteHead
1010
public GitOid Oid;
1111
public GitOid Loid;
1212
public IntPtr NamePtr;
13+
public IntPtr SymRefTargetPtr;
1314
}
1415
}

LibGit2Sharp/Core/GitStatusOptions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,7 @@ internal enum GitStatusOptionFlags
4949
SortCaseSensitively = (1 << 9),
5050
SortCaseInsensitively = (1 << 10),
5151
RenamesFromRewrites = (1 << 11),
52+
NoRefresh = (1 << 12),
53+
UpdateIndex = (1 << 13),
5254
}
5355
}

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-06d772d";
5+
public const string Name = "git2-58eea5e";
66
}
77
}

LibGit2Sharp/Core/NativeMethods.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,9 @@ internal static extern int git_config_next(
380380
[DllImport(libgit2)]
381381
internal static extern void git_config_iterator_free(IntPtr iter);
382382

383+
[DllImport(libgit2)]
384+
internal static extern int git_config_snapshot(out ConfigurationSafeHandle @out, ConfigurationSafeHandle config);
385+
383386
// Ordinarily we would decorate the `url` parameter with the StrictUtf8Marshaler like we do everywhere
384387
// else, but apparently doing a native->managed callback with the 64-bit version of CLR 2.0 can
385388
// sometimes vomit when using a custom IMarshaler. So yeah, don't do that. If you need the url,
@@ -621,6 +624,7 @@ internal static extern int git_merge(
621624
[DllImport(libgit2)]
622625
internal static extern int git_merge_analysis(
623626
out GitMergeAnalysis status_out,
627+
out GitMergePreference preference_out,
624628
RepositorySafeHandle repo,
625629
[In] IntPtr[] their_heads,
626630
int their_heads_len);
@@ -633,7 +637,8 @@ internal static extern void git_merge_head_free(
633637
internal static extern int git_message_prettify(
634638
GitBuf buf,
635639
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string message,
636-
[MarshalAs(UnmanagedType.Bool)] bool strip_comments);
640+
[MarshalAs(UnmanagedType.Bool)] bool strip_comments,
641+
sbyte comment_char);
637642

638643
[DllImport(libgit2)]
639644
internal static extern int git_note_create(

LibGit2Sharp/Core/Proxy.cs

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,18 @@ public static void git_config_iterator_free(IntPtr iter)
569569
NativeMethods.git_config_iterator_free(iter);
570570
}
571571

572+
public static ConfigurationSafeHandle git_config_snapshot(ConfigurationSafeHandle config)
573+
{
574+
using (ThreadAffinity())
575+
{
576+
ConfigurationSafeHandle handle;
577+
int res = NativeMethods.git_config_snapshot(out handle, config);
578+
Ensure.ZeroResult(res);
579+
580+
return handle;
581+
}
582+
}
583+
572584
#endregion
573585

574586
#region git_diff_
@@ -1022,25 +1034,24 @@ public static void git_merge(RepositorySafeHandle repo, GitMergeHeadHandle[] hea
10221034
}
10231035
}
10241036

1025-
public static GitMergeAnalysis git_merge_analysis(
1037+
public static void git_merge_analysis(
10261038
RepositorySafeHandle repo,
1027-
GitMergeHeadHandle[] heads)
1039+
GitMergeHeadHandle[] heads,
1040+
out GitMergeAnalysis analysis_out,
1041+
out GitMergePreference preference_out)
10281042
{
10291043
using (ThreadAffinity())
10301044
{
1031-
GitMergeAnalysis ret;
1032-
10331045
IntPtr[] their_heads = heads.Select(head => head.DangerousGetHandle()).ToArray();
10341046

10351047
int res = NativeMethods.git_merge_analysis(
1036-
out ret,
1048+
out analysis_out,
1049+
out preference_out,
10371050
repo,
10381051
their_heads,
10391052
their_heads.Length);
10401053

10411054
Ensure.ZeroResult(res);
1042-
1043-
return ret;
10441055
}
10451056
}
10461057

@@ -1063,7 +1074,7 @@ public static string git_message_prettify(string message)
10631074
using (ThreadAffinity())
10641075
using (var buf = new GitBuf())
10651076
{
1066-
int res= NativeMethods.git_message_prettify(buf, message, false);
1077+
int res= NativeMethods.git_message_prettify(buf, message, false, (sbyte)'#');
10671078
Ensure.Int32Result(res);
10681079

10691080
return LaxUtf8Marshaler.FromNative(buf.ptr) ?? string.Empty;

LibGit2Sharp/Repository.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1251,7 +1251,10 @@ public RevertResult Revert(Commit commit, Signature reverter, RevertOptions opti
12511251
/// <returns>The <see cref="MergeResult"/> of the merge.</returns>
12521252
private MergeResult Merge(GitMergeHeadHandle[] mergeHeads, Signature merger, MergeOptions options)
12531253
{
1254-
GitMergeAnalysis mergeAnalysis = Proxy.git_merge_analysis(Handle, mergeHeads);
1254+
GitMergeAnalysis mergeAnalysis;
1255+
GitMergePreference mergePreference;
1256+
1257+
Proxy.git_merge_analysis(Handle, mergeHeads, out mergeAnalysis, out mergePreference);
12551258

12561259
MergeResult mergeResult = null;
12571260

LibGit2Sharp/libgit2_hash.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
06d772d8d45e3e2830614a62a51910547afb6666
1+
58eea5ebf40b698cbaf028b23ee6157d5eb6582c

libgit2

Submodule libgit2 updated 431 files

0 commit comments

Comments
 (0)