Skip to content

Commit bf722af

Browse files
committed
Upgrade libgit2 binaries to 54be4d5
libgit2/libgit2@1e99ce9...54be4d5 Conflicts: LibGit2Sharp/Core/NativeMethods.cs
1 parent 47eb4ba commit bf722af

21 files changed

+162
-53
lines changed

Lib/NativeBinaries/amd64/git2.dll

14 KB
Binary file not shown.

Lib/NativeBinaries/amd64/git2.pdb

576 KB
Binary file not shown.

Lib/NativeBinaries/x86/git2.dll

10 KB
Binary file not shown.

Lib/NativeBinaries/x86/git2.pdb

96 KB
Binary file not shown.

LibGit2Sharp.Tests/CommitFixture.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public void CanCorrectlyCountCommitsWhenSwitchingToAnotherBranch()
3030
{
3131
repo.Reset(ResetOptions.Hard);
3232

33-
repo.Checkout("test");
33+
repo.Checkout("test", CheckoutOptions.Force, null);
3434
Assert.Equal(2, repo.Commits.Count());
3535
Assert.Equal("e90810b8df3e80c413d903f631643c716887138d", repo.Commits.First().Id.Sha);
3636

@@ -229,8 +229,8 @@ public void CanEnumerateFromDetachedHead()
229229
{
230230
repoClone.Reset(ResetOptions.Hard);
231231

232-
string headSha = repoClone.Head.Tip.Sha;
233-
repoClone.Checkout(headSha);
232+
Branch head = repoClone.Head;
233+
repoClone.Checkout(head, CheckoutOptions.Force, null);
234234

235235
AssertEnumerationOfCommitsInRepo(repoClone,
236236
repo => new Filter { Since = repo.Head },

LibGit2Sharp.Tests/ConfigurationFixture.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public void CanUnsetAnEntryFromTheGlobalConfiguration()
7777
.AppendFormat("Man-I-am-totally-global = 42{0}", Environment.NewLine);
7878

7979
File.WriteAllText(globalLocation, sb.ToString());
80+
File.WriteAllText(systemLocation, string.Empty);
8081

8182
var options = new RepositoryOptions
8283
{

LibGit2Sharp.Tests/RepositoryOptionsFixture.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ public void CanProvideDifferentConfigurationFilesToARepository()
157157
.AppendFormat("email = {0}{1}", email, Environment.NewLine);
158158

159159
File.WriteAllText(globalLocation, sb.ToString());
160+
File.WriteAllText(systemLocation, string.Empty);
160161

161162
var options = new RepositoryOptions {
162163
GlobalConfigurationLocation = globalLocation,

LibGit2Sharp.Tests/ResetHeadFixture.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public void HardResetUpdatesTheContentOfTheWorkingDirectory()
174174
names.Sort(StringComparer.Ordinal);
175175

176176
File.Delete(Path.Combine(repo.Info.WorkingDirectory, "README"));
177-
File.WriteAllText(Path.Combine(repo.Info.WorkingDirectory, "WillBeRemoved.txt"), "content\n");
177+
File.WriteAllText(Path.Combine(repo.Info.WorkingDirectory, "WillNotBeRemoved.txt"), "content\n");
178178

179179
Assert.True(names.Count > 4);
180180

@@ -183,7 +183,7 @@ public void HardResetUpdatesTheContentOfTheWorkingDirectory()
183183
names = new DirectoryInfo(repo.Info.WorkingDirectory).GetFileSystemInfos().Select(fsi => fsi.Name).ToList();
184184
names.Sort(StringComparer.Ordinal);
185185

186-
Assert.Equal(new[] { ".git", "README", "branch_file.txt", "new.txt" }, names);
186+
Assert.Equal(new[] { ".git", "README", "WillNotBeRemoved.txt", "branch_file.txt", "new.txt", "new_untracked_file.txt" }, names);
187187
}
188188
}
189189
}

LibGit2Sharp/Core/GitCheckoutOpts.cs

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33

44
namespace LibGit2Sharp.Core
55
{
6-
internal delegate int skipped_notify_cb(
7-
IntPtr skipped_file,
6+
internal delegate int conflict_cb(
7+
IntPtr conflicting_path,
88
ref GitOid blob_oid,
9-
int file_mode,
10-
IntPtr payload);
9+
uint index_mode,
10+
uint wd_mode,
11+
IntPtr payload);
1112

1213
internal delegate void progress_cb(
1314
IntPtr strPtr,
@@ -23,8 +24,8 @@ internal class GitCheckoutOpts
2324
public int DirMode;
2425
public int FileMode;
2526
public int FileOpenFlags;
26-
public skipped_notify_cb skippedNotifyCb;
27-
public IntPtr NotifyPayload;
27+
public conflict_cb conflictCb;
28+
public IntPtr ConflictPayload;
2829
public progress_cb ProgressCb;
2930
public IntPtr ProgressPayload;
3031
public UnSafeNativeMethods.git_strarray paths;
@@ -33,9 +34,51 @@ internal class GitCheckoutOpts
3334
[Flags]
3435
internal enum CheckoutStrategy
3536
{
36-
GIT_CHECKOUT_DEFAULT = (1 << 0),
37-
GIT_CHECKOUT_OVERWRITE_MODIFIED = (1 << 1),
38-
GIT_CHECKOUT_CREATE_MISSING = (1 << 2),
39-
GIT_CHECKOUT_REMOVE_UNTRACKED = (1 << 3),
37+
GIT_CHECKOUT_DEFAULT = 0, /** default is a dry run, no actual updates */
38+
39+
/** Allow update of entries where working dir matches HEAD. */
40+
GIT_CHECKOUT_UPDATE_UNMODIFIED = (1 << 0),
41+
42+
/** Allow update of entries where working dir does not have file. */
43+
GIT_CHECKOUT_UPDATE_MISSING = (1 << 1),
44+
45+
/** Allow safe updates that cannot overwrite uncommited data */
46+
GIT_CHECKOUT_SAFE =
47+
(GIT_CHECKOUT_UPDATE_UNMODIFIED | GIT_CHECKOUT_UPDATE_MISSING),
48+
49+
/** Allow update of entries in working dir that are modified from HEAD. */
50+
GIT_CHECKOUT_UPDATE_MODIFIED = (1 << 2),
51+
52+
/** Update existing untracked files that are now present in the index. */
53+
GIT_CHECKOUT_UPDATE_UNTRACKED = (1 << 3),
54+
55+
/** Allow all updates to force working directory to look like index */
56+
GIT_CHECKOUT_FORCE =
57+
(GIT_CHECKOUT_SAFE | GIT_CHECKOUT_UPDATE_MODIFIED | GIT_CHECKOUT_UPDATE_UNTRACKED),
58+
59+
/** Allow checkout to make updates even if conflicts are found */
60+
GIT_CHECKOUT_ALLOW_CONFLICTS = (1 << 4),
61+
62+
/** Remove untracked files not in index (that are not ignored) */
63+
GIT_CHECKOUT_REMOVE_UNTRACKED = (1 << 5),
64+
65+
/** Only update existing files, don't create new ones */
66+
GIT_CHECKOUT_UPDATE_ONLY = (1 << 6),
67+
68+
/**
69+
* THE FOLLOWING OPTIONS ARE NOT YET IMPLEMENTED
70+
*/
71+
72+
/** Allow checkout to skip unmerged files (NOT IMPLEMENTED) */
73+
GIT_CHECKOUT_SKIP_UNMERGED = (1 << 10),
74+
/** For unmerged files, checkout stage 2 from index (NOT IMPLEMENTED) */
75+
GIT_CHECKOUT_USE_OURS = (1 << 11),
76+
/** For unmerged files, checkout stage 3 from index (NOT IMPLEMENTED) */
77+
GIT_CHECKOUT_USE_THEIRS = (1 << 12),
78+
79+
/** Recursively checkout submodules with same options (NOT IMPLEMENTED) */
80+
GIT_CHECKOUT_UPDATE_SUBMODULES = (1 << 16),
81+
/** Recursively checkout submodules if HEAD moved in super repo (NOT IMPLEMENTED) */
82+
GIT_CHECKOUT_UPDATE_SUBMODULES_IF_CHANGED = (1 << 17),
4083
}
4184
}

LibGit2Sharp/Core/GitDiff.cs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,60 @@ namespace LibGit2Sharp.Core
66
[Flags]
77
internal enum GitDiffOptionFlags
88
{
9+
/** Normal diff, the default */
910
GIT_DIFF_NORMAL = 0,
11+
/** Reverse the sides of the diff */
1012
GIT_DIFF_REVERSE = (1 << 0),
13+
/** Treat all files as text, disabling binary attributes & detection */
1114
GIT_DIFF_FORCE_TEXT = (1 << 1),
15+
/** Ignore all whitespace */
1216
GIT_DIFF_IGNORE_WHITESPACE = (1 << 2),
17+
/** Ignore changes in amount of whitespace */
1318
GIT_DIFF_IGNORE_WHITESPACE_CHANGE = (1 << 3),
19+
/** Ignore whitespace at end of line */
1420
GIT_DIFF_IGNORE_WHITESPACE_EOL = (1 << 4),
21+
/** Exclude submodules from the diff completely */
1522
GIT_DIFF_IGNORE_SUBMODULES = (1 << 5),
23+
/** Use the "patience diff" algorithm (currently unimplemented) */
1624
GIT_DIFF_PATIENCE = (1 << 6),
25+
/** Include ignored files in the diff list */
1726
GIT_DIFF_INCLUDE_IGNORED = (1 << 7),
27+
/** Include untracked files in the diff list */
1828
GIT_DIFF_INCLUDE_UNTRACKED = (1 << 8),
29+
/** Include unmodified files in the diff list */
30+
GIT_DIFF_INCLUDE_UNMODIFIED = (1 << 9),
31+
/** Even with the GIT_DIFF_INCLUDE_UNTRACKED flag, when an untracked
32+
* directory is found, only a single entry for the directory is added
33+
* to the diff list; with this flag, all files under the directory will
34+
* be included, too.
35+
*/
36+
GIT_DIFF_RECURSE_UNTRACKED_DIRS = (1 << 10),
37+
/** If the pathspec is set in the diff options, this flags means to
38+
* apply it as an exact match instead of as an fnmatch pattern.
39+
*/
40+
GIT_DIFF_DISABLE_PATHSPEC_MATCH = (1 << 11),
41+
/** Use case insensitive filename comparisons */
42+
GIT_DIFF_DELTAS_ARE_ICASE = (1 << 12),
43+
/** When generating patch text, include the content of untracked files */
44+
GIT_DIFF_INCLUDE_UNTRACKED_CONTENT = (1 << 13),
45+
/** Disable updating of the `binary` flag in delta records. This is
46+
* useful when iterating over a diff if you don't need hunk and data
47+
* callbacks and want to avoid having to load file completely.
48+
*/
49+
GIT_DIFF_SKIP_BINARY_CHECK = (1 << 14),
50+
/** Normally, a type change between files will be converted into a
51+
* DELETED record for the old and an ADDED record for the new; this
52+
* options enabled the generation of TYPECHANGE delta records.
53+
*/
54+
GIT_DIFF_INCLUDE_TYPECHANGE = (1 << 15),
55+
/** Even with GIT_DIFF_INCLUDE_TYPECHANGE, blob->tree changes still
56+
* generally show as a DELETED blob. This flag tries to correctly
57+
* label blob->tree transitions as TYPECHANGE records with new_file's
58+
* mode set to tree. Note: the tree SHA will not be available.
59+
*/
60+
GIT_DIFF_INCLUDE_TYPECHANGE_TREES = (1 << 16),
61+
/** Ignore file mode changes */
62+
GIT_DIFF_IGNORE_FILEMODE = (1 << 17),
1963
}
2064

2165
[StructLayout(LayoutKind.Sequential)]

LibGit2Sharp/Core/GitErrorCategory.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,10 @@ internal enum GitErrorCategory
1818
Tag,
1919
Tree,
2020
Indexer,
21+
Ssl,
22+
Submodule,
23+
Thread,
24+
Stash,
25+
Checkout,
2126
}
2227
}

LibGit2Sharp/Core/GitErrorCode.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ internal enum GitErrorCode
3535
/// </summary>
3636
BareRepo = -8,
3737

38+
/// <summary>
39+
/// Operation cannot be performed against an orphaned HEAD.
40+
/// </summary>
41+
OrphanedHead = -9,
42+
43+
/// <summary>
44+
/// Operation cannot be performed against a not fully merged index.
45+
/// </summary>
46+
UnmergedEntries = -8,
47+
3848
/// <summary>
3949
/// Skip and passthrough the given ODB backend.
4050
/// </summary>

LibGit2Sharp/Core/GitOdbBackend.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ static GitOdbBackend()
2929
public readstream_callback ReadStream;
3030
public exists_callback Exists;
3131
public foreach_callback Foreach;
32+
public IntPtr Writepack;
3233
public free_callback Free;
3334

3435
/* The libgit2 structure definition ends here. Subsequent fields are for libgit2sharp bookkeeping. */

LibGit2Sharp/Core/NativeMethods.cs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ internal static extern int git_checkout_head(
160160
[DllImport(libgit2)]
161161
internal static extern int git_checkout_index(
162162
RepositorySafeHandle repo,
163+
IndexSafeHandle index,
163164
GitCheckoutOpts opts);
164165

165166
[DllImport(libgit2)]
@@ -308,18 +309,19 @@ internal static extern int git_config_foreach(
308309

309310
[DllImport(libgit2)]
310311
internal static extern int git_diff_tree_to_tree(
312+
out DiffListSafeHandle diff,
311313
RepositorySafeHandle repo,
312-
GitDiffOptions options,
313314
GitObjectSafeHandle oldTree,
314315
GitObjectSafeHandle newTree,
315-
out DiffListSafeHandle diff);
316+
GitDiffOptions options);
316317

317318
[DllImport(libgit2)]
318319
internal static extern int git_diff_index_to_tree(
320+
out DiffListSafeHandle diff,
319321
RepositorySafeHandle repo,
320-
GitDiffOptions options,
321322
GitObjectSafeHandle oldTree,
322-
out DiffListSafeHandle diff);
323+
IndexSafeHandle index,
324+
GitDiffOptions options);
323325

324326
[DllImport(libgit2)]
325327
internal static extern int git_diff_merge(
@@ -328,16 +330,17 @@ internal static extern int git_diff_merge(
328330

329331
[DllImport(libgit2)]
330332
internal static extern int git_diff_workdir_to_index(
333+
out DiffListSafeHandle diff,
331334
RepositorySafeHandle repo,
332-
GitDiffOptions options,
333-
out DiffListSafeHandle diff);
335+
IndexSafeHandle index,
336+
GitDiffOptions options);
334337

335338
[DllImport(libgit2)]
336339
internal static extern int git_diff_workdir_to_tree(
340+
out DiffListSafeHandle diff,
337341
RepositorySafeHandle repo,
338-
GitDiffOptions options,
339342
GitObjectSafeHandle oldTree,
340-
out DiffListSafeHandle diff);
343+
GitDiffOptions options);
341344

342345
internal delegate int git_diff_file_fn(
343346
IntPtr data,
@@ -819,10 +822,10 @@ internal static extern int git_tag_delete(
819822
internal static extern OidSafeHandle git_tag_target_oid(GitObjectSafeHandle tag);
820823

821824
[DllImport(libgit2)]
822-
internal static extern GitObjectType git_tag_type(GitObjectSafeHandle tag);
825+
internal static extern GitObjectType git_tag_target_type(GitObjectSafeHandle tag);
823826

824827
[DllImport(libgit2)]
825-
internal static extern void git_threads_init();
828+
internal static extern int git_threads_init();
826829

827830
[DllImport(libgit2)]
828831
internal static extern void git_threads_shutdown();

LibGit2Sharp/Core/Proxy.cs

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,11 @@ public static void git_checkout_head(RepositorySafeHandle repo, GitCheckoutOpts
188188
}
189189
}
190190

191-
public static void git_checkout_index(RepositorySafeHandle repo, GitCheckoutOpts opts)
191+
public static void git_checkout_index(RepositorySafeHandle repo, IndexSafeHandle index, GitCheckoutOpts opts)
192192
{
193193
using (ThreadAffinity())
194194
{
195-
int res = NativeMethods.git_checkout_index(repo, opts);
195+
int res = NativeMethods.git_checkout_index(repo, index, opts);
196196
Ensure.Success(res);
197197
}
198198
}
@@ -515,14 +515,15 @@ public static void git_diff_blobs(
515515

516516
public static DiffListSafeHandle git_diff_index_to_tree(
517517
RepositorySafeHandle repo,
518-
GitDiffOptions options,
519-
ObjectId oldTree)
518+
IndexSafeHandle index,
519+
ObjectId oldTree,
520+
GitDiffOptions options)
520521
{
521522
using (ThreadAffinity())
522523
using (var osw = new ObjectSafeWrapper(oldTree, repo))
523524
{
524525
DiffListSafeHandle diff;
525-
int res = NativeMethods.git_diff_index_to_tree(repo, options, osw.ObjectPtr, out diff);
526+
int res = NativeMethods.git_diff_index_to_tree(out diff, repo, osw.ObjectPtr, index, options);
526527
Ensure.Success(res);
527528

528529
return diff;
@@ -554,16 +555,16 @@ public static void git_diff_print_patch(DiffListSafeHandle diff, NativeMethods.g
554555

555556
public static DiffListSafeHandle git_diff_tree_to_tree(
556557
RepositorySafeHandle repo,
557-
GitDiffOptions options,
558558
ObjectId oldTree,
559-
ObjectId newTree)
559+
ObjectId newTree,
560+
GitDiffOptions options)
560561
{
561562
using (ThreadAffinity())
562563
using (var osw1 = new ObjectSafeWrapper(oldTree, repo))
563564
using (var osw2 = new ObjectSafeWrapper(newTree, repo))
564565
{
565566
DiffListSafeHandle diff;
566-
int res = NativeMethods.git_diff_tree_to_tree(repo, options, osw1.ObjectPtr, osw2.ObjectPtr, out diff);
567+
int res = NativeMethods.git_diff_tree_to_tree(out diff, repo, osw1.ObjectPtr, osw2.ObjectPtr, options);
567568
Ensure.Success(res);
568569

569570
return diff;
@@ -572,12 +573,13 @@ public static DiffListSafeHandle git_diff_tree_to_tree(
572573

573574
public static DiffListSafeHandle git_diff_workdir_to_index(
574575
RepositorySafeHandle repo,
576+
IndexSafeHandle index,
575577
GitDiffOptions options)
576578
{
577579
using (ThreadAffinity())
578580
{
579581
DiffListSafeHandle diff;
580-
int res = NativeMethods.git_diff_workdir_to_index(repo, options, out diff);
582+
int res = NativeMethods.git_diff_workdir_to_index(out diff, repo, index, options);
581583
Ensure.Success(res);
582584

583585
return diff;
@@ -586,14 +588,14 @@ public static DiffListSafeHandle git_diff_workdir_to_index(
586588

587589
public static DiffListSafeHandle git_diff_workdir_to_tree(
588590
RepositorySafeHandle repo,
589-
GitDiffOptions options,
590-
ObjectId oldTree)
591+
ObjectId oldTree,
592+
GitDiffOptions options)
591593
{
592594
using (ThreadAffinity())
593595
using (var osw = new ObjectSafeWrapper(oldTree, repo))
594596
{
595597
DiffListSafeHandle diff;
596-
int res = NativeMethods.git_diff_workdir_to_tree(repo, options, osw.ObjectPtr, out diff);
598+
int res = NativeMethods.git_diff_workdir_to_tree(out diff, repo, osw.ObjectPtr, options);
597599
Ensure.Success(res);
598600

599601
return diff;
@@ -1581,9 +1583,9 @@ public static ObjectId git_tag_target_oid(GitObjectSafeHandle tag)
15811583
return NativeMethods.git_tag_target_oid(tag).MarshalAsObjectId();
15821584
}
15831585

1584-
public static GitObjectType git_tag_type(GitObjectSafeHandle tag)
1586+
public static GitObjectType git_tag_target_type(GitObjectSafeHandle tag)
15851587
{
1586-
return NativeMethods.git_tag_type(tag);
1588+
return NativeMethods.git_tag_target_type(tag);
15871589
}
15881590

15891591
#endregion

0 commit comments

Comments
 (0)