diff --git a/.gitignore b/.gitignore index 6c668f7cc..8bb24a91b 100644 --- a/.gitignore +++ b/.gitignore @@ -34,4 +34,8 @@ _ReSharper*/ *.pidb *.userprefs *.swp -*.DotSettings \ No newline at end of file +*.DotSettings +#Ignore custom generated files +LibGit2Sharp/Core/UniqueIdentifier.cs + +!Lib/NativeBinaries/*/*.pdb diff --git a/.travis.yml b/.travis.yml index 496884376..b0930caa6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,8 +11,10 @@ install: script: - git submodule update --init - mkdir cmake-build + - LIBGIT2SHA=`cat ./LibGit2Sharp/libgit2_hash.txt` + - SHORTSHA=${LIBGIT2SHA:0:7} - cd cmake-build - - cmake -DTHREADSAFE=ON -DCMAKE_BUILD_TYPE=Release -DBUILD_CLAR=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=./libgit2-bin ../libgit2 + - cmake -DTHREADSAFE=ON -DCMAKE_BUILD_TYPE=Release -DBUILD_CLAR=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=./libgit2-bin -DSONAME_APPEND=$SHORTSHA ../libgit2 - export LD_LIBRARY_PATH=$PWD/libgit2-bin/lib - cmake --build . --target install - cd .. diff --git a/CHANGES.md b/CHANGES.md index c9a37f6ff..f8dbc4c32 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,6 +8,25 @@ - CI server: - @libgit2sharp: +## v0.12.0 - ([diff](https://github.com/libgit2/libgit2sharp/compare/v0.11.0...v0.12.0)) + +### Additions + + - Introduce repo.Info.IsShallow + - Teach repo.Reset to append to the Reflog + - Introduce repo.ObjectDatabase.CreateTag() + - Make repo.Diff.Compare() able to define the expected number of context and interhunk lines (#423) + +### Changes + + - Obsolete TreeEntryTargetType.Tag + - Update libgit2 binaries to libgit2/libgit2@9d9fff3 + +### Fixes + + - Change probing mechanism to rely on specifically named versions of libgit2 binaries (#241) + - Ensure that two versions of LibGit2Sharp can run side by side (#241) + ## v0.11.0 - ([diff](https://github.com/libgit2/libgit2sharp/compare/v0.10.0...v0.11.0)) ### Additions diff --git a/Lib/CustomBuildTasks/CustomBuildTasks.csproj b/Lib/CustomBuildTasks/CustomBuildTasks.csproj new file mode 100644 index 000000000..2da370371 --- /dev/null +++ b/Lib/CustomBuildTasks/CustomBuildTasks.csproj @@ -0,0 +1,42 @@ + + + + + Debug + AnyCPU + {B6138573-A4B9-44E7-83C2-8964CAF51EDA} + Library + Properties + CustomBuildTasks + CustomBuildTasks + v3.5 + 512 + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + diff --git a/Lib/CustomBuildTasks/CustomBuildTasks.dll b/Lib/CustomBuildTasks/CustomBuildTasks.dll new file mode 100644 index 000000000..3cd023b83 Binary files /dev/null and b/Lib/CustomBuildTasks/CustomBuildTasks.dll differ diff --git a/Lib/CustomBuildTasks/GenerateUniqueIdentifierTask.cs b/Lib/CustomBuildTasks/GenerateUniqueIdentifierTask.cs new file mode 100644 index 000000000..2f26ac94d --- /dev/null +++ b/Lib/CustomBuildTasks/GenerateUniqueIdentifierTask.cs @@ -0,0 +1,36 @@ +using System; +using System.IO; +using System.Text; +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; + +namespace CustomBuildTasks +{ + public class GenerateUniqueIdentifierTask : Task + { + public override bool Execute() + { + using (FileStream fs = new FileStream(this.OutputFile, FileMode.Create, FileAccess.Write, FileShare.None)) + using (StreamWriter sw = new StreamWriter(fs, Encoding.UTF8)) + { + sw.WriteLine("using System;"); + sw.WriteLine(); + sw.WriteLine("namespace LibGit2Sharp.Core"); + sw.WriteLine("{"); + sw.WriteLine(" internal static class UniqueId"); + sw.WriteLine(" {"); + sw.WriteLine(" public const String UniqueIdentifier = \"" + Guid.NewGuid().ToString() + "\";"); + sw.WriteLine(" }"); + sw.WriteLine("}"); + } + + return true; + } + + public String OutputFile + { + get; + set; + } + } +} diff --git a/Lib/NativeBinaries/amd64/git2-9d9fff3.dll b/Lib/NativeBinaries/amd64/git2-9d9fff3.dll new file mode 100644 index 000000000..1c4d5f176 Binary files /dev/null and b/Lib/NativeBinaries/amd64/git2-9d9fff3.dll differ diff --git a/Lib/NativeBinaries/amd64/git2.pdb b/Lib/NativeBinaries/amd64/git2-9d9fff3.pdb similarity index 56% rename from Lib/NativeBinaries/amd64/git2.pdb rename to Lib/NativeBinaries/amd64/git2-9d9fff3.pdb index a6088a28d..6a8bb33be 100644 Binary files a/Lib/NativeBinaries/amd64/git2.pdb and b/Lib/NativeBinaries/amd64/git2-9d9fff3.pdb differ diff --git a/Lib/NativeBinaries/amd64/git2.dll b/Lib/NativeBinaries/amd64/git2.dll deleted file mode 100644 index ed03a1695..000000000 Binary files a/Lib/NativeBinaries/amd64/git2.dll and /dev/null differ diff --git a/Lib/NativeBinaries/x86/git2-9d9fff3.dll b/Lib/NativeBinaries/x86/git2-9d9fff3.dll new file mode 100644 index 000000000..0c94ac714 Binary files /dev/null and b/Lib/NativeBinaries/x86/git2-9d9fff3.dll differ diff --git a/Lib/NativeBinaries/x86/git2.pdb b/Lib/NativeBinaries/x86/git2-9d9fff3.pdb similarity index 54% rename from Lib/NativeBinaries/x86/git2.pdb rename to Lib/NativeBinaries/x86/git2-9d9fff3.pdb index 979b5d379..93be3f06b 100644 Binary files a/Lib/NativeBinaries/x86/git2.pdb and b/Lib/NativeBinaries/x86/git2-9d9fff3.pdb differ diff --git a/Lib/NativeBinaries/x86/git2.dll b/Lib/NativeBinaries/x86/git2.dll deleted file mode 100644 index 5846aeff7..000000000 Binary files a/Lib/NativeBinaries/x86/git2.dll and /dev/null differ diff --git a/Lib/NuGet/NuGet.exe b/Lib/NuGet/NuGet.exe index c3960af62..cb3ed0367 100644 Binary files a/Lib/NuGet/NuGet.exe and b/Lib/NuGet/NuGet.exe differ diff --git a/LibGit2Sharp.Tests/CheckoutFixture.cs b/LibGit2Sharp.Tests/CheckoutFixture.cs index 8bdca0a8f..ebeed6c19 100644 --- a/LibGit2Sharp.Tests/CheckoutFixture.cs +++ b/LibGit2Sharp.Tests/CheckoutFixture.cs @@ -500,9 +500,7 @@ public void CheckoutRetainsIgnoredChanges() string ignoredFilePath = Path.Combine(repo.Info.WorkingDirectory, Path.Combine("bin", "some_ignored_file.txt")); File.WriteAllText(ignoredFilePath, "hello from this ignored file."); - // The following check does not report ignored entries... - // TODO: Uncomment once libgit2/libgit2#1251 is merged - // Assert.Equal(1, repo.Index.RetrieveStatus().Ignored.Count()); + Assert.Equal(1, repo.Index.RetrieveStatus().Ignored.Count()); Assert.Equal(FileStatus.Ignored, repo.Index.RetrieveStatus(ignoredFilePath)); @@ -531,9 +529,7 @@ public void ForceCheckoutRetainsIgnoredChanges() string ignoredFilePath = Path.Combine(repo.Info.WorkingDirectory, Path.Combine("bin", "some_ignored_file.txt")); File.WriteAllText(ignoredFilePath, "hello from this ignored file."); - // The following check does not report ignored entries... - // TODO: Uncomment once libgit2/libgit2#1251 is merged - // Assert.Equal(1, repo.Index.RetrieveStatus().Ignored.Count()); + Assert.Equal(1, repo.Index.RetrieveStatus().Ignored.Count()); Assert.Equal(FileStatus.Ignored, repo.Index.RetrieveStatus(ignoredFilePath)); diff --git a/LibGit2Sharp.Tests/DiffTreeToTreeFixture.cs b/LibGit2Sharp.Tests/DiffTreeToTreeFixture.cs index f291cd6dd..a40070b5c 100644 --- a/LibGit2Sharp.Tests/DiffTreeToTreeFixture.cs +++ b/LibGit2Sharp.Tests/DiffTreeToTreeFixture.cs @@ -4,6 +4,7 @@ using System.Text; using LibGit2Sharp.Tests.TestHelpers; using Xunit; +using Xunit.Extensions; namespace LibGit2Sharp.Tests { @@ -222,23 +223,31 @@ public void CanDetectTheRenamingOfAModifiedFile() * $ git diff --shortstat f8d44d7..ec9e401 * 1 file changed, 2 insertions(+), 1 deletion(-) */ - [Fact] - public void CanCompareTwoVersionsOfAFileWithATrailingNewlineDeletion() + [Theory] + [InlineData(0, 175)] + [InlineData(1, 191)] + [InlineData(2, 184)] + [InlineData(3, 187)] + [InlineData(4, 193)] + public void CanCompareTwoVersionsOfAFileWithATrailingNewlineDeletion(int contextLines, int expectedPatchLength) { using (var repo = new Repository(StandardTestRepoPath)) { Tree rootCommitTree = repo.Lookup("f8d44d7").Tree; Tree commitTreeWithUpdatedFile = repo.Lookup("ec9e401").Tree; - TreeChanges changes = repo.Diff.Compare(rootCommitTree, commitTreeWithUpdatedFile); + TreeChanges changes = repo.Diff.Compare(rootCommitTree, commitTreeWithUpdatedFile, + compareOptions: new CompareOptions { ContextLines = contextLines }); Assert.Equal(1, changes.Count()); Assert.Equal(1, changes.Modified.Count()); + Assert.Equal(expectedPatchLength, changes.Patch.Length); TreeEntryChanges treeEntryChanges = changes.Modified.Single(); Assert.Equal(2, treeEntryChanges.LinesAdded); Assert.Equal(1, treeEntryChanges.LinesDeleted); + Assert.Equal(expectedPatchLength, treeEntryChanges.Patch.Length); } } @@ -293,15 +302,31 @@ public void CanCompareTwoVersionsOfAFileWithATrailingNewlineDeletion() * super-file.txt | 5 +++++ * 3 files changed, 8 insertions(+), 5 deletions(-) */ - [Fact] - public void CanCompareTwoVersionsOfAFileWithADiffOfTwoHunks() + [Theory] + [InlineData(0, 3)] + [InlineData(0, 4)] + [InlineData(1, 1)] + [InlineData(1, 2)] + [InlineData(2, 4)] + [InlineData(2, 5)] + [InlineData(3, 2)] + [InlineData(3, 3)] + [InlineData(4, 0)] + [InlineData(4, 1)] + public void CanCompareTwoVersionsOfAFileWithADiffOfTwoHunks(int contextLines, int interhunkLines) { + var compareOptions = new CompareOptions + { + ContextLines = contextLines, + InterhunkLines = interhunkLines, + }; + using (var repo = new Repository(StandardTestRepoPath)) { Tree rootCommitTree = repo.Lookup("f8d44d7").Tree; Tree mergedCommitTree = repo.Lookup("7252fe2").Tree; - TreeChanges changes = repo.Diff.Compare(rootCommitTree, mergedCommitTree); + TreeChanges changes = repo.Diff.Compare(rootCommitTree, mergedCommitTree, compareOptions: compareOptions); Assert.Equal(3, changes.Count()); Assert.Equal(1, changes.Modified.Count()); @@ -314,77 +339,10 @@ public void CanCompareTwoVersionsOfAFileWithADiffOfTwoHunks() Assert.Equal(1, treeEntryChanges.LinesDeleted); Assert.Equal(Mode.Nonexistent, changes["my-name-does-not-feel-right.txt"].Mode); - - var expected = new StringBuilder() - .Append("diff --git a/numbers.txt b/numbers.txt\n") - .Append("index 7909961..4e935b7 100644\n") - .Append("--- a/numbers.txt\n") - .Append("+++ b/numbers.txt\n") - .Append("@@ -1,4 +1,5 @@\n") - .Append(" 1\n") - .Append("+2\n") - .Append(" 3\n") - .Append(" 4\n") - .Append(" 5\n") - .Append("@@ -8,8 +9,9 @@\n") - .Append(" 8\n") - .Append(" 9\n") - .Append(" 10\n") - .Append("-12\n") - .Append("+11\n") - .Append(" 12\n") - .Append(" 13\n") - .Append(" 14\n") - .Append(" 15\n") - .Append("+16\n"); - - Assert.Equal(expected.ToString(), treeEntryChanges.Patch); - - expected = new StringBuilder() - .Append("diff --git a/my-name-does-not-feel-right.txt b/my-name-does-not-feel-right.txt\n") - .Append("deleted file mode 100644\n") - .Append("index e8953ab..0000000\n") - .Append("--- a/my-name-does-not-feel-right.txt\n") - .Append("+++ /dev/null\n") - .Append("@@ -1,4 +0,0 @@\n") - .Append("-That's a terrible name!\n") - .Append("-I don't like it.\n") - .Append("-People look down at me and laugh. :-(\n") - .Append("-Really!!!!\n") - .Append("diff --git a/numbers.txt b/numbers.txt\n") - .Append("index 7909961..4e935b7 100644\n") - .Append("--- a/numbers.txt\n") - .Append("+++ b/numbers.txt\n") - .Append("@@ -1,4 +1,5 @@\n") - .Append(" 1\n") - .Append("+2\n") - .Append(" 3\n") - .Append(" 4\n") - .Append(" 5\n") - .Append("@@ -8,8 +9,9 @@\n") - .Append(" 8\n") - .Append(" 9\n") - .Append(" 10\n") - .Append("-12\n") - .Append("+11\n") - .Append(" 12\n") - .Append(" 13\n") - .Append(" 14\n") - .Append(" 15\n") - .Append("+16\n") - .Append("diff --git a/super-file.txt b/super-file.txt\n") - .Append("new file mode 100644\n") - .Append("index 0000000..16bdf1d\n") - .Append("--- /dev/null\n") - .Append("+++ b/super-file.txt\n") - .Append("@@ -0,0 +1,5 @@\n") - .Append("+That's a terrible name!\n") - .Append("+I don't like it.\n") - .Append("+People look down at me and laugh. :-(\n") - .Append("+Really!!!!\n") - .Append("+Yeah! Better!\n"); - - Assert.Equal(expected.ToString(), changes.Patch); + Assert.Equal(Expected("f8d44d7...7252fe2/numbers.txt-{0}-{1}.diff", contextLines, interhunkLines), + treeEntryChanges.Patch); + Assert.Equal(Expected("f8d44d7...7252fe2/full-{0}-{1}.diff", contextLines, interhunkLines), + changes.Patch); } } @@ -395,8 +353,8 @@ public void CanHandleTwoTreeEntryChangesWithTheSamePath() using (Repository repo = Repository.Init(scd.DirectoryPath)) { - Blob mainContent = CreateBlob(repo, "awesome content\n"); - Blob linkContent = CreateBlob(repo, "../../objc/Nu.h"); + Blob mainContent = OdbHelper.CreateBlob(repo, "awesome content\n"); + Blob linkContent = OdbHelper.CreateBlob(repo, "../../objc/Nu.h"); string path = string.Format("include{0}Nu{0}Nu.h", Path.DirectorySeparatorChar); @@ -451,15 +409,6 @@ public void CanHandleTwoTreeEntryChangesWithTheSamePath() } } - private static Blob CreateBlob(Repository repo, string content) - { - using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(content))) - using (var binReader = new BinaryReader(stream)) - { - return repo.ObjectDatabase.CreateBlob(binReader); - } - } - [Fact] public void CanCompareATreeAgainstANullTree() { @@ -488,7 +437,7 @@ public void ComparingTwoNullTreesReturnsAnEmptyTreeChanges() { using (var repo = new Repository(StandardTestRepoPath)) { - TreeChanges changes = repo.Diff.Compare(null, null, null); + TreeChanges changes = repo.Diff.Compare(default(Tree), default(Tree)); Assert.Equal(0, changes.Count()); } @@ -558,5 +507,38 @@ private RepositoryOptions BuildFakeSystemConfigFilemodeOption( return options; } + + [Fact] + public void RetrievingDiffChangesMustAlwaysBeCaseSensitive() + { + SelfCleaningDirectory scd = BuildSelfCleaningDirectory(); + ObjectId treeOldOid, treeNewOid; + + using (Repository repo = Repository.Init(scd.DirectoryPath)) + { + Blob oldContent = OdbHelper.CreateBlob(repo, "awesome content\n"); + Blob newContent = OdbHelper.CreateBlob(repo, "more awesome content\n"); + + var td = new TreeDefinition() + .Add("A.TXT", oldContent, Mode.NonExecutableFile) + .Add("a.txt", oldContent, Mode.NonExecutableFile); + + treeOldOid = repo.ObjectDatabase.CreateTree(td).Id; + + td = new TreeDefinition() + .Add("A.TXT", newContent, Mode.NonExecutableFile) + .Add("a.txt", newContent, Mode.NonExecutableFile); + + treeNewOid = repo.ObjectDatabase.CreateTree(td).Id; + } + + using (var repo = new Repository(scd.DirectoryPath)) + { + var changes = repo.Diff.Compare(repo.Lookup(treeOldOid), repo.Lookup(treeNewOid)); + + Assert.Equal(ChangeKind.Modified, changes["a.txt"].Status); + Assert.Equal(ChangeKind.Modified, changes["A.TXT"].Status); + } + } } } diff --git a/LibGit2Sharp.Tests/FetchFixture.cs b/LibGit2Sharp.Tests/FetchFixture.cs index d2e7c9fa9..f40dcd667 100644 --- a/LibGit2Sharp.Tests/FetchFixture.cs +++ b/LibGit2Sharp.Tests/FetchFixture.cs @@ -82,13 +82,7 @@ public void CanFetchAllTagsIntoAnEmptyRepository(string url) TestRemoteInfo remoteInfo = TestRemoteInfo.TestRemoteInstance; var expectedFetchState = new ExpectedFetchState(remoteName); - // Add expected branch objects - foreach (KeyValuePair kvp in remoteInfo.BranchTips) - { - expectedFetchState.AddExpectedBranch(kvp.Key, ObjectId.Zero, kvp.Value); - } - - // Add expected tags + // Add expected tags only as no branches are expected to be fetched foreach (KeyValuePair kvp in remoteInfo.Tags) { expectedFetchState.AddExpectedTag(kvp.Key, ObjectId.Zero, kvp.Value); diff --git a/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj b/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj index 6fe9acb94..f9dc8766f 100644 --- a/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj +++ b/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj @@ -104,6 +104,7 @@ + diff --git a/LibGit2Sharp.Tests/MetaFixture.cs b/LibGit2Sharp.Tests/MetaFixture.cs index 91ca9bbad..340f1352e 100644 --- a/LibGit2Sharp.Tests/MetaFixture.cs +++ b/LibGit2Sharp.Tests/MetaFixture.cs @@ -12,13 +12,14 @@ public class MetaFixture { private static readonly Type[] excludedTypes = new[] { + typeof(CompareOptions), typeof(Credentials), + typeof(ExplicitPathsOptions), typeof(Filter), typeof(ObjectId), typeof(Repository), typeof(RepositoryOptions), typeof(Signature), - typeof(ExplicitPathsOptions), }; // Related to https://github.com/libgit2/libgit2sharp/pull/251 diff --git a/LibGit2Sharp.Tests/ObjectDatabaseFixture.cs b/LibGit2Sharp.Tests/ObjectDatabaseFixture.cs index 3c398855d..a845e8068 100644 --- a/LibGit2Sharp.Tests/ObjectDatabaseFixture.cs +++ b/LibGit2Sharp.Tests/ObjectDatabaseFixture.cs @@ -338,5 +338,31 @@ public void CanCreateABinaryBlobFromABinaryReader() } } } + + [Fact] + public void CanCreateATagAnnotationPointingToAGitObject() + { + string path = CloneBareTestRepo(); + using (var repo = new Repository(path)) + { + var blob = repo.Head.Tip["README"].Target as Blob; + Assert.NotNull(blob); + + TagAnnotation tag = repo.ObjectDatabase.CreateTag( + "nice_blob", + blob, + DummySignature, + "I can point at blobs, too!"); + + Assert.NotNull(tag); + + // The TagAnnotation is not pointed at by any reference... + Assert.Null(repo.Tags["nice_blob"]); + + // ...but exists in the odb. + var fetched = repo.Lookup(tag.Id); + Assert.Equal(tag, fetched); + } + } } } diff --git a/LibGit2Sharp.Tests/ReferenceFixture.cs b/LibGit2Sharp.Tests/ReferenceFixture.cs index dea5489ce..85da6bb44 100644 --- a/LibGit2Sharp.Tests/ReferenceFixture.cs +++ b/LibGit2Sharp.Tests/ReferenceFixture.cs @@ -778,20 +778,5 @@ public void CanIdentifyReferenceKind() Assert.True(repo.Refs["refs/notes/commits"].IsNote()); } } - - private static void AssertReflogEntryIsCreated(IEnumerable reflog, string targetSha, string logMessage, string fromSha = null) - { - var reflogEntry = reflog.First(); - - if (!string.IsNullOrEmpty(fromSha)) - { - Assert.Equal(fromSha, reflogEntry.From.Sha); - } - - Assert.Equal(targetSha, reflogEntry.To.Sha); - Assert.NotNull(reflogEntry.Commiter.Email); - Assert.NotNull(reflogEntry.Commiter.Name); - Assert.Equal(logMessage, reflogEntry.Message); - } } } diff --git a/LibGit2Sharp.Tests/RepositoryFixture.cs b/LibGit2Sharp.Tests/RepositoryFixture.cs index 628b3050b..6a8819767 100644 --- a/LibGit2Sharp.Tests/RepositoryFixture.cs +++ b/LibGit2Sharp.Tests/RepositoryFixture.cs @@ -538,5 +538,19 @@ public void AccessingADeletedHeadThrows() Assert.Throws(() => repo.Head); } } + + [Fact] + public void CanDetectShallowness() + { + using (var repo = new Repository(ShallowTestRepoPath)) + { + Assert.True(repo.Info.IsShallow); + } + + using (var repo = new Repository(StandardTestRepoPath)) + { + Assert.False(repo.Info.IsShallow); + } + } } } diff --git a/LibGit2Sharp.Tests/ResetHeadFixture.cs b/LibGit2Sharp.Tests/ResetHeadFixture.cs index 195f147a1..18c392c13 100644 --- a/LibGit2Sharp.Tests/ResetHeadFixture.cs +++ b/LibGit2Sharp.Tests/ResetHeadFixture.cs @@ -25,7 +25,8 @@ public void ResetANewlyInitializedRepositoryThrows(bool isBare) [Fact] public void SoftResetToTheHeadOfARepositoryDoesNotChangeTheTargetOfTheHead() { - using (var repo = new Repository(BareTestRepoPath)) + string path = CloneBareTestRepo(); + using (var repo = new Repository(path)) { Branch oldHead = repo.Head; @@ -101,6 +102,7 @@ private void AssertSoftReset(Func branchIdentifierRetriever, boo string branchIdentifier = branchIdentifierRetriever(branch); repo.Checkout(branchIdentifier); + var oldHeadSha = repo.Head.Tip.Sha; Assert.Equal(shouldHeadBeDetached, repo.Info.IsHeadDetached); string expectedHeadName = expectedHeadNameRetriever(branch); @@ -114,12 +116,16 @@ private void AssertSoftReset(Func branchIdentifierRetriever, boo Assert.Equal(FileStatus.Staged, repo.Index.RetrieveStatus("a.txt")); + AssertReflogEntryIsCreated(repo.Refs.Log(repo.Refs.Head), tag.Target.Sha, string.Format("reset: moving to {0}", tag.Target.Sha), oldHeadSha); + /* Reset --soft the Head to a commit through its sha */ repo.Reset(ResetOptions.Soft, branch.Tip.Sha); Assert.Equal(expectedHeadName, repo.Head.Name); Assert.Equal(branch.Tip.Sha, repo.Head.Tip.Sha); Assert.Equal(FileStatus.Unaltered, repo.Index.RetrieveStatus("a.txt")); + + AssertReflogEntryIsCreated(repo.Refs.Log(repo.Refs.Head), branch.Tip.Sha, string.Format("reset: moving to {0}", branch.Tip.Sha), tag.Target.Sha); } } @@ -157,6 +163,9 @@ public void MixedResetRefreshesTheIndex() repo.Reset(ResetOptions.Mixed, tag.CanonicalName); Assert.Equal(FileStatus.Modified, repo.Index.RetrieveStatus("a.txt")); + + AssertReflogEntryIsCreated(repo.Refs.Log(repo.Refs.Head), tag.Target.Sha, string.Format("reset: moving to {0}", tag.Target.Sha)); + } } diff --git a/LibGit2Sharp.Tests/ResetIndexFixture.cs b/LibGit2Sharp.Tests/ResetIndexFixture.cs index 8b3a1e2f2..b9903b579 100644 --- a/LibGit2Sharp.Tests/ResetIndexFixture.cs +++ b/LibGit2Sharp.Tests/ResetIndexFixture.cs @@ -67,10 +67,15 @@ public void ResetTheIndexWithTheHeadUnstagesEverything() RepositoryStatus oldStatus = repo.Index.RetrieveStatus(); Assert.Equal(3, oldStatus.Where(IsStaged).Count()); + var reflogEntriesCount = repo.Refs.Log(repo.Refs.Head).Count(); + repo.Reset(); RepositoryStatus newStatus = repo.Index.RetrieveStatus(); Assert.Equal(0, newStatus.Where(IsStaged).Count()); + + // Assert that no reflog entry is created + Assert.Equal(reflogEntriesCount, repo.Refs.Log(repo.Refs.Head).Count()); } } diff --git a/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/full-0-3.diff b/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/full-0-3.diff new file mode 100644 index 000000000..8f1024340 --- /dev/null +++ b/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/full-0-3.diff @@ -0,0 +1,32 @@ +diff --git a/my-name-does-not-feel-right.txt b/my-name-does-not-feel-right.txt +deleted file mode 100644 +index e8953ab..0000000 +--- a/my-name-does-not-feel-right.txt ++++ /dev/null +@@ -1,4 +0,0 @@ +-That's a terrible name! +-I don't like it. +-People look down at me and laugh. :-( +-Really!!!! +diff --git a/numbers.txt b/numbers.txt +index 7909961..4e935b7 100644 +--- a/numbers.txt ++++ b/numbers.txt +@@ -1,0 +2 @@ ++2 +@@ -11 +12 @@ +-12 ++11 +@@ -15,0 +17 @@ ++16 +diff --git a/super-file.txt b/super-file.txt +new file mode 100644 +index 0000000..16bdf1d +--- /dev/null ++++ b/super-file.txt +@@ -0,0 +1,5 @@ ++That's a terrible name! ++I don't like it. ++People look down at me and laugh. :-( ++Really!!!! ++Yeah! Better! diff --git a/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/full-0-4.diff b/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/full-0-4.diff new file mode 100644 index 000000000..ac0db32e5 --- /dev/null +++ b/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/full-0-4.diff @@ -0,0 +1,35 @@ +diff --git a/my-name-does-not-feel-right.txt b/my-name-does-not-feel-right.txt +deleted file mode 100644 +index e8953ab..0000000 +--- a/my-name-does-not-feel-right.txt ++++ /dev/null +@@ -1,4 +0,0 @@ +-That's a terrible name! +-I don't like it. +-People look down at me and laugh. :-( +-Really!!!! +diff --git a/numbers.txt b/numbers.txt +index 7909961..4e935b7 100644 +--- a/numbers.txt ++++ b/numbers.txt +@@ -1,0 +2 @@ ++2 +@@ -11,5 +12,6 @@ +-12 ++11 + 12 + 13 + 14 + 15 ++16 +diff --git a/super-file.txt b/super-file.txt +new file mode 100644 +index 0000000..16bdf1d +--- /dev/null ++++ b/super-file.txt +@@ -0,0 +1,5 @@ ++That's a terrible name! ++I don't like it. ++People look down at me and laugh. :-( ++Really!!!! ++Yeah! Better! diff --git a/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/full-1-1.diff b/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/full-1-1.diff new file mode 100644 index 000000000..0447955c4 --- /dev/null +++ b/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/full-1-1.diff @@ -0,0 +1,37 @@ +diff --git a/my-name-does-not-feel-right.txt b/my-name-does-not-feel-right.txt +deleted file mode 100644 +index e8953ab..0000000 +--- a/my-name-does-not-feel-right.txt ++++ /dev/null +@@ -1,4 +0,0 @@ +-That's a terrible name! +-I don't like it. +-People look down at me and laugh. :-( +-Really!!!! +diff --git a/numbers.txt b/numbers.txt +index 7909961..4e935b7 100644 +--- a/numbers.txt ++++ b/numbers.txt +@@ -1,2 +1,3 @@ + 1 ++2 + 3 +@@ -10,3 +11,3 @@ + 10 +-12 ++11 + 12 +@@ -15 +16,2 @@ + 15 ++16 +diff --git a/super-file.txt b/super-file.txt +new file mode 100644 +index 0000000..16bdf1d +--- /dev/null ++++ b/super-file.txt +@@ -0,0 +1,5 @@ ++That's a terrible name! ++I don't like it. ++People look down at me and laugh. :-( ++Really!!!! ++Yeah! Better! diff --git a/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/full-1-2.diff b/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/full-1-2.diff new file mode 100644 index 000000000..6f1be86c9 --- /dev/null +++ b/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/full-1-2.diff @@ -0,0 +1,38 @@ +diff --git a/my-name-does-not-feel-right.txt b/my-name-does-not-feel-right.txt +deleted file mode 100644 +index e8953ab..0000000 +--- a/my-name-does-not-feel-right.txt ++++ /dev/null +@@ -1,4 +0,0 @@ +-That's a terrible name! +-I don't like it. +-People look down at me and laugh. :-( +-Really!!!! +diff --git a/numbers.txt b/numbers.txt +index 7909961..4e935b7 100644 +--- a/numbers.txt ++++ b/numbers.txt +@@ -1,2 +1,3 @@ + 1 ++2 + 3 +@@ -10,6 +11,7 @@ + 10 +-12 ++11 + 12 + 13 + 14 + 15 ++16 +diff --git a/super-file.txt b/super-file.txt +new file mode 100644 +index 0000000..16bdf1d +--- /dev/null ++++ b/super-file.txt +@@ -0,0 +1,5 @@ ++That's a terrible name! ++I don't like it. ++People look down at me and laugh. :-( ++Really!!!! ++Yeah! Better! diff --git a/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/full-2-4.diff b/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/full-2-4.diff new file mode 100644 index 000000000..a470e39c0 --- /dev/null +++ b/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/full-2-4.diff @@ -0,0 +1,40 @@ +diff --git a/my-name-does-not-feel-right.txt b/my-name-does-not-feel-right.txt +deleted file mode 100644 +index e8953ab..0000000 +--- a/my-name-does-not-feel-right.txt ++++ /dev/null +@@ -1,4 +0,0 @@ +-That's a terrible name! +-I don't like it. +-People look down at me and laugh. :-( +-Really!!!! +diff --git a/numbers.txt b/numbers.txt +index 7909961..4e935b7 100644 +--- a/numbers.txt ++++ b/numbers.txt +@@ -1,3 +1,4 @@ + 1 ++2 + 3 + 4 +@@ -9,7 +10,8 @@ + 9 + 10 +-12 ++11 + 12 + 13 + 14 + 15 ++16 +diff --git a/super-file.txt b/super-file.txt +new file mode 100644 +index 0000000..16bdf1d +--- /dev/null ++++ b/super-file.txt +@@ -0,0 +1,5 @@ ++That's a terrible name! ++I don't like it. ++People look down at me and laugh. :-( ++Really!!!! ++Yeah! Better! diff --git a/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/full-2-5.diff b/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/full-2-5.diff new file mode 100644 index 000000000..ae602bcc5 --- /dev/null +++ b/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/full-2-5.diff @@ -0,0 +1,44 @@ +diff --git a/my-name-does-not-feel-right.txt b/my-name-does-not-feel-right.txt +deleted file mode 100644 +index e8953ab..0000000 +--- a/my-name-does-not-feel-right.txt ++++ /dev/null +@@ -1,4 +0,0 @@ +-That's a terrible name! +-I don't like it. +-People look down at me and laugh. :-( +-Really!!!! +diff --git a/numbers.txt b/numbers.txt +index 7909961..4e935b7 100644 +--- a/numbers.txt ++++ b/numbers.txt +@@ -1,15 +1,17 @@ + 1 ++2 + 3 + 4 + 5 + 6 + 7 + 7.2 + 8 + 9 + 10 +-12 ++11 + 12 + 13 + 14 + 15 ++16 +diff --git a/super-file.txt b/super-file.txt +new file mode 100644 +index 0000000..16bdf1d +--- /dev/null ++++ b/super-file.txt +@@ -0,0 +1,5 @@ ++That's a terrible name! ++I don't like it. ++People look down at me and laugh. :-( ++Really!!!! ++Yeah! Better! diff --git a/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/full-3-2.diff b/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/full-3-2.diff new file mode 100644 index 000000000..2037795d1 --- /dev/null +++ b/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/full-3-2.diff @@ -0,0 +1,42 @@ +diff --git a/my-name-does-not-feel-right.txt b/my-name-does-not-feel-right.txt +deleted file mode 100644 +index e8953ab..0000000 +--- a/my-name-does-not-feel-right.txt ++++ /dev/null +@@ -1,4 +0,0 @@ +-That's a terrible name! +-I don't like it. +-People look down at me and laugh. :-( +-Really!!!! +diff --git a/numbers.txt b/numbers.txt +index 7909961..4e935b7 100644 +--- a/numbers.txt ++++ b/numbers.txt +@@ -1,4 +1,5 @@ + 1 ++2 + 3 + 4 + 5 +@@ -8,8 +9,9 @@ + 8 + 9 + 10 +-12 ++11 + 12 + 13 + 14 + 15 ++16 +diff --git a/super-file.txt b/super-file.txt +new file mode 100644 +index 0000000..16bdf1d +--- /dev/null ++++ b/super-file.txt +@@ -0,0 +1,5 @@ ++That's a terrible name! ++I don't like it. ++People look down at me and laugh. :-( ++Really!!!! ++Yeah! Better! diff --git a/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/full-3-3.diff b/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/full-3-3.diff new file mode 100644 index 000000000..ae602bcc5 --- /dev/null +++ b/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/full-3-3.diff @@ -0,0 +1,44 @@ +diff --git a/my-name-does-not-feel-right.txt b/my-name-does-not-feel-right.txt +deleted file mode 100644 +index e8953ab..0000000 +--- a/my-name-does-not-feel-right.txt ++++ /dev/null +@@ -1,4 +0,0 @@ +-That's a terrible name! +-I don't like it. +-People look down at me and laugh. :-( +-Really!!!! +diff --git a/numbers.txt b/numbers.txt +index 7909961..4e935b7 100644 +--- a/numbers.txt ++++ b/numbers.txt +@@ -1,15 +1,17 @@ + 1 ++2 + 3 + 4 + 5 + 6 + 7 + 7.2 + 8 + 9 + 10 +-12 ++11 + 12 + 13 + 14 + 15 ++16 +diff --git a/super-file.txt b/super-file.txt +new file mode 100644 +index 0000000..16bdf1d +--- /dev/null ++++ b/super-file.txt +@@ -0,0 +1,5 @@ ++That's a terrible name! ++I don't like it. ++People look down at me and laugh. :-( ++Really!!!! ++Yeah! Better! diff --git a/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/full-4-0.diff b/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/full-4-0.diff new file mode 100644 index 000000000..d624e0d73 --- /dev/null +++ b/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/full-4-0.diff @@ -0,0 +1,44 @@ +diff --git a/my-name-does-not-feel-right.txt b/my-name-does-not-feel-right.txt +deleted file mode 100644 +index e8953ab..0000000 +--- a/my-name-does-not-feel-right.txt ++++ /dev/null +@@ -1,4 +0,0 @@ +-That's a terrible name! +-I don't like it. +-People look down at me and laugh. :-( +-Really!!!! +diff --git a/numbers.txt b/numbers.txt +index 7909961..4e935b7 100644 +--- a/numbers.txt ++++ b/numbers.txt +@@ -1,5 +1,6 @@ + 1 ++2 + 3 + 4 + 5 + 6 +@@ -7,9 +8,10 @@ + 7.2 + 8 + 9 + 10 +-12 ++11 + 12 + 13 + 14 + 15 ++16 +diff --git a/super-file.txt b/super-file.txt +new file mode 100644 +index 0000000..16bdf1d +--- /dev/null ++++ b/super-file.txt +@@ -0,0 +1,5 @@ ++That's a terrible name! ++I don't like it. ++People look down at me and laugh. :-( ++Really!!!! ++Yeah! Better! diff --git a/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/full-4-1.diff b/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/full-4-1.diff new file mode 100644 index 000000000..ae602bcc5 --- /dev/null +++ b/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/full-4-1.diff @@ -0,0 +1,44 @@ +diff --git a/my-name-does-not-feel-right.txt b/my-name-does-not-feel-right.txt +deleted file mode 100644 +index e8953ab..0000000 +--- a/my-name-does-not-feel-right.txt ++++ /dev/null +@@ -1,4 +0,0 @@ +-That's a terrible name! +-I don't like it. +-People look down at me and laugh. :-( +-Really!!!! +diff --git a/numbers.txt b/numbers.txt +index 7909961..4e935b7 100644 +--- a/numbers.txt ++++ b/numbers.txt +@@ -1,15 +1,17 @@ + 1 ++2 + 3 + 4 + 5 + 6 + 7 + 7.2 + 8 + 9 + 10 +-12 ++11 + 12 + 13 + 14 + 15 ++16 +diff --git a/super-file.txt b/super-file.txt +new file mode 100644 +index 0000000..16bdf1d +--- /dev/null ++++ b/super-file.txt +@@ -0,0 +1,5 @@ ++That's a terrible name! ++I don't like it. ++People look down at me and laugh. :-( ++Really!!!! ++Yeah! Better! diff --git a/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/numbers.txt-0-3.diff b/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/numbers.txt-0-3.diff new file mode 100644 index 000000000..c14970b01 --- /dev/null +++ b/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/numbers.txt-0-3.diff @@ -0,0 +1,11 @@ +diff --git a/numbers.txt b/numbers.txt +index 7909961..4e935b7 100644 +--- a/numbers.txt ++++ b/numbers.txt +@@ -1,0 +2 @@ ++2 +@@ -11 +12 @@ +-12 ++11 +@@ -15,0 +17 @@ ++16 diff --git a/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/numbers.txt-0-4.diff b/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/numbers.txt-0-4.diff new file mode 100644 index 000000000..4c2236c7b --- /dev/null +++ b/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/numbers.txt-0-4.diff @@ -0,0 +1,14 @@ +diff --git a/numbers.txt b/numbers.txt +index 7909961..4e935b7 100644 +--- a/numbers.txt ++++ b/numbers.txt +@@ -1,0 +2 @@ ++2 +@@ -11,5 +12,6 @@ +-12 ++11 + 12 + 13 + 14 + 15 ++16 diff --git a/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/numbers.txt-1-1.diff b/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/numbers.txt-1-1.diff new file mode 100644 index 000000000..5ad039099 --- /dev/null +++ b/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/numbers.txt-1-1.diff @@ -0,0 +1,16 @@ +diff --git a/numbers.txt b/numbers.txt +index 7909961..4e935b7 100644 +--- a/numbers.txt ++++ b/numbers.txt +@@ -1,2 +1,3 @@ + 1 ++2 + 3 +@@ -10,3 +11,3 @@ + 10 +-12 ++11 + 12 +@@ -15 +16,2 @@ + 15 ++16 diff --git a/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/numbers.txt-1-2.diff b/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/numbers.txt-1-2.diff new file mode 100644 index 000000000..7a5fda643 --- /dev/null +++ b/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/numbers.txt-1-2.diff @@ -0,0 +1,17 @@ +diff --git a/numbers.txt b/numbers.txt +index 7909961..4e935b7 100644 +--- a/numbers.txt ++++ b/numbers.txt +@@ -1,2 +1,3 @@ + 1 ++2 + 3 +@@ -10,6 +11,7 @@ + 10 +-12 ++11 + 12 + 13 + 14 + 15 ++16 diff --git a/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/numbers.txt-2-4.diff b/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/numbers.txt-2-4.diff new file mode 100644 index 000000000..9311b08fc --- /dev/null +++ b/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/numbers.txt-2-4.diff @@ -0,0 +1,19 @@ +diff --git a/numbers.txt b/numbers.txt +index 7909961..4e935b7 100644 +--- a/numbers.txt ++++ b/numbers.txt +@@ -1,3 +1,4 @@ + 1 ++2 + 3 + 4 +@@ -9,7 +10,8 @@ + 9 + 10 +-12 ++11 + 12 + 13 + 14 + 15 ++16 diff --git a/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/numbers.txt-2-5.diff b/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/numbers.txt-2-5.diff new file mode 100644 index 000000000..26e01b51f --- /dev/null +++ b/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/numbers.txt-2-5.diff @@ -0,0 +1,23 @@ +diff --git a/numbers.txt b/numbers.txt +index 7909961..4e935b7 100644 +--- a/numbers.txt ++++ b/numbers.txt +@@ -1,15 +1,17 @@ + 1 ++2 + 3 + 4 + 5 + 6 + 7 + 7.2 + 8 + 9 + 10 +-12 ++11 + 12 + 13 + 14 + 15 ++16 diff --git a/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/numbers.txt-3-2.diff b/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/numbers.txt-3-2.diff new file mode 100644 index 000000000..9f55b2e05 --- /dev/null +++ b/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/numbers.txt-3-2.diff @@ -0,0 +1,21 @@ +diff --git a/numbers.txt b/numbers.txt +index 7909961..4e935b7 100644 +--- a/numbers.txt ++++ b/numbers.txt +@@ -1,4 +1,5 @@ + 1 ++2 + 3 + 4 + 5 +@@ -8,8 +9,9 @@ + 8 + 9 + 10 +-12 ++11 + 12 + 13 + 14 + 15 ++16 diff --git a/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/numbers.txt-3-3.diff b/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/numbers.txt-3-3.diff new file mode 100644 index 000000000..26e01b51f --- /dev/null +++ b/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/numbers.txt-3-3.diff @@ -0,0 +1,23 @@ +diff --git a/numbers.txt b/numbers.txt +index 7909961..4e935b7 100644 +--- a/numbers.txt ++++ b/numbers.txt +@@ -1,15 +1,17 @@ + 1 ++2 + 3 + 4 + 5 + 6 + 7 + 7.2 + 8 + 9 + 10 +-12 ++11 + 12 + 13 + 14 + 15 ++16 diff --git a/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/numbers.txt-4-0.diff b/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/numbers.txt-4-0.diff new file mode 100644 index 000000000..9ec9021ef --- /dev/null +++ b/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/numbers.txt-4-0.diff @@ -0,0 +1,23 @@ +diff --git a/numbers.txt b/numbers.txt +index 7909961..4e935b7 100644 +--- a/numbers.txt ++++ b/numbers.txt +@@ -1,5 +1,6 @@ + 1 ++2 + 3 + 4 + 5 + 6 +@@ -7,9 +8,10 @@ + 7.2 + 8 + 9 + 10 +-12 ++11 + 12 + 13 + 14 + 15 ++16 diff --git a/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/numbers.txt-4-1.diff b/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/numbers.txt-4-1.diff new file mode 100644 index 000000000..26e01b51f --- /dev/null +++ b/LibGit2Sharp.Tests/Resources/expected/f8d44d7...7252fe2/numbers.txt-4-1.diff @@ -0,0 +1,23 @@ +diff --git a/numbers.txt b/numbers.txt +index 7909961..4e935b7 100644 +--- a/numbers.txt ++++ b/numbers.txt +@@ -1,15 +1,17 @@ + 1 ++2 + 3 + 4 + 5 + 6 + 7 + 7.2 + 8 + 9 + 10 +-12 ++11 + 12 + 13 + 14 + 15 ++16 diff --git a/LibGit2Sharp.Tests/Resources/shallow.git/HEAD b/LibGit2Sharp.Tests/Resources/shallow.git/HEAD new file mode 100644 index 000000000..cb089cd89 --- /dev/null +++ b/LibGit2Sharp.Tests/Resources/shallow.git/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/LibGit2Sharp.Tests/Resources/shallow.git/config b/LibGit2Sharp.Tests/Resources/shallow.git/config new file mode 100644 index 000000000..a88b74b69 --- /dev/null +++ b/LibGit2Sharp.Tests/Resources/shallow.git/config @@ -0,0 +1,8 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = true + ignorecase = true + precomposeunicode = false +[remote "origin"] + url = file://testrepo.git diff --git a/LibGit2Sharp.Tests/Resources/shallow.git/objects/pack/pack-706e49b161700946489570d96153e5be4dc31ad4.idx b/LibGit2Sharp.Tests/Resources/shallow.git/objects/pack/pack-706e49b161700946489570d96153e5be4dc31ad4.idx new file mode 100644 index 000000000..bfc7d24ff Binary files /dev/null and b/LibGit2Sharp.Tests/Resources/shallow.git/objects/pack/pack-706e49b161700946489570d96153e5be4dc31ad4.idx differ diff --git a/LibGit2Sharp.Tests/Resources/shallow.git/objects/pack/pack-706e49b161700946489570d96153e5be4dc31ad4.pack b/LibGit2Sharp.Tests/Resources/shallow.git/objects/pack/pack-706e49b161700946489570d96153e5be4dc31ad4.pack new file mode 100644 index 000000000..ccc6932fc Binary files /dev/null and b/LibGit2Sharp.Tests/Resources/shallow.git/objects/pack/pack-706e49b161700946489570d96153e5be4dc31ad4.pack differ diff --git a/LibGit2Sharp.Tests/Resources/shallow.git/packed-refs b/LibGit2Sharp.Tests/Resources/shallow.git/packed-refs new file mode 100644 index 000000000..97eed743b --- /dev/null +++ b/LibGit2Sharp.Tests/Resources/shallow.git/packed-refs @@ -0,0 +1,2 @@ +# pack-refs with: peeled +a65fedf39aefe402d3bb6e24df4d4f5fe4547750 refs/heads/master diff --git a/LibGit2Sharp.Tests/Resources/shallow.git/refs/.gitkeep b/LibGit2Sharp.Tests/Resources/shallow.git/refs/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/LibGit2Sharp.Tests/Resources/shallow.git/shallow b/LibGit2Sharp.Tests/Resources/shallow.git/shallow new file mode 100644 index 000000000..9536ad89c --- /dev/null +++ b/LibGit2Sharp.Tests/Resources/shallow.git/shallow @@ -0,0 +1 @@ +be3563ae3f795b2b4353bcce3a527ad0a4f7f644 diff --git a/LibGit2Sharp.Tests/StatusFixture.cs b/LibGit2Sharp.Tests/StatusFixture.cs index 45681677d..618a765fe 100644 --- a/LibGit2Sharp.Tests/StatusFixture.cs +++ b/LibGit2Sharp.Tests/StatusFixture.cs @@ -1,6 +1,7 @@ using System; using System.IO; using System.Linq; +using System.Text; using LibGit2Sharp.Tests.TestHelpers; using Xunit; using Xunit.Extensions; @@ -310,5 +311,41 @@ private static void AssertStatus(bool shouldIgnoreCase, FileStatus expectedFileS Assert.False(shouldIgnoreCase); } } + + [Fact] + public void RetrievingTheStatusOfTheRepositoryHonorsTheGitIgnoreDirectivesThroughoutDirectories() + { + char dirSep = Path.DirectorySeparatorChar; + + string path = CloneStandardTestRepo(); + using (var repo = new Repository(path)) + { + Touch(repo.Info.WorkingDirectory, "bin/look-ma.txt", "I'm going to be ignored!"); + Touch(repo.Info.WorkingDirectory, "bin/what-about-me.txt", "Huh?"); + + string gitignorePath = Path.Combine(repo.Info.WorkingDirectory, ".gitignore"); + + File.WriteAllText(gitignorePath, "bin"); + + Assert.Equal(FileStatus.Ignored, repo.Index.RetrieveStatus("bin/look-ma.txt")); + Assert.Equal(FileStatus.Ignored, repo.Index.RetrieveStatus("bin/what-about-me.txt")); + + RepositoryStatus newStatus = repo.Index.RetrieveStatus(); + Assert.Equal(new[] { "bin" + dirSep }, newStatus.Ignored); + + var sb = new StringBuilder(); + sb.AppendLine("bin/*"); + sb.AppendLine("!bin/w*"); + File.WriteAllText(gitignorePath, sb.ToString()); + + Assert.Equal(FileStatus.Ignored, repo.Index.RetrieveStatus("bin/look-ma.txt")); + Assert.Equal(FileStatus.Untracked, repo.Index.RetrieveStatus("bin/what-about-me.txt")); + + newStatus = repo.Index.RetrieveStatus(); + + Assert.Equal(new[] { "bin" + dirSep + "look-ma.txt" }, newStatus.Ignored); + Assert.True(newStatus.Untracked.Contains("bin" + dirSep + "what-about-me.txt" )); + } + } } } diff --git a/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs b/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs index 2158b590f..316c68ec1 100644 --- a/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs +++ b/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.IO; +using System.Linq; using System.Text; using System.Text.RegularExpressions; using LibGit2Sharp.Core; @@ -21,6 +23,7 @@ static BaseFixture() public static string BareTestRepoPath { get; private set; } public static string StandardTestRepoWorkingDirPath { get; private set; } public static string StandardTestRepoPath { get; private set; } + public static string ShallowTestRepoPath { get; private set; } public static string MergedTestRepoWorkingDirPath { get; private set; } public static string SubmoduleTestRepoWorkingDirPath { get; private set; } public static DirectoryInfo ResourcesDirectory { get; private set; } @@ -54,6 +57,7 @@ private static void SetUpTestEnvironment() BareTestRepoPath = Path.Combine(ResourcesDirectory.FullName, "testrepo.git"); StandardTestRepoWorkingDirPath = Path.Combine(ResourcesDirectory.FullName, "testrepo_wd"); StandardTestRepoPath = Path.Combine(StandardTestRepoWorkingDirPath, ".git"); + ShallowTestRepoPath = Path.Combine(ResourcesDirectory.FullName, "shallow.git"); MergedTestRepoWorkingDirPath = Path.Combine(ResourcesDirectory.FullName, "mergedrepo_wd"); SubmoduleTestRepoWorkingDirPath = Path.Combine(ResourcesDirectory.FullName, "submodule_wd"); } @@ -221,5 +225,31 @@ protected string Touch(string parent, string file, string content = null) return file; } + + protected static void AssertReflogEntryIsCreated(IEnumerable reflog, string targetSha, + string logMessage, string fromSha = null) + { + var reflogEntry = reflog.First(); + + if (!string.IsNullOrEmpty(fromSha)) + { + Assert.Equal(fromSha, reflogEntry.From.Sha); + } + + Assert.Equal(targetSha, reflogEntry.To.Sha); + Assert.NotNull(reflogEntry.Commiter.Email); + Assert.NotNull(reflogEntry.Commiter.Name); + Assert.Equal(logMessage, reflogEntry.Message); + } + + protected string Expected(string filename) + { + return File.ReadAllText(Path.Combine(ResourcesDirectory.FullName, "expected/" + filename)); + } + + protected string Expected(string filenameFormat, params object[] args) + { + return Expected(string.Format(CultureInfo.InvariantCulture, filenameFormat, args)); + } } } diff --git a/LibGit2Sharp.Tests/TestHelpers/OdbHelper.cs b/LibGit2Sharp.Tests/TestHelpers/OdbHelper.cs new file mode 100644 index 000000000..83e21ecf3 --- /dev/null +++ b/LibGit2Sharp.Tests/TestHelpers/OdbHelper.cs @@ -0,0 +1,17 @@ +using System.IO; +using System.Text; + +namespace LibGit2Sharp.Tests.TestHelpers +{ + public static class OdbHelper + { + public static Blob CreateBlob(Repository repo, string content) + { + using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(content))) + using (var binReader = new BinaryReader(stream)) + { + return repo.ObjectDatabase.CreateBlob(binReader); + } + } + } +} diff --git a/LibGit2Sharp/BranchUpdater.cs b/LibGit2Sharp/BranchUpdater.cs index ce5b87eb2..60d403d14 100644 --- a/LibGit2Sharp/BranchUpdater.cs +++ b/LibGit2Sharp/BranchUpdater.cs @@ -28,25 +28,6 @@ internal BranchUpdater(Repository repo, Branch branch) this.branch = branch; } - /// - /// Sets the upstream information for the branch. - /// - /// Passing null or string.Empty will unset the upstream. - /// - /// - /// The upstream branch name is with respect to the current repository. - /// So, passing "refs/remotes/origin/master" will set the current branch - /// to track "refs/heads/master" on the origin. Passing in - /// "refs/heads/master" will result in the branch tracking the local - /// master branch. - /// - /// - [Obsolete("This property will be removed in the next release. Please use BranchUpdate.TrackedBranch instead.")] - public virtual string Upstream - { - set { TrackedBranch = value; } - } - /// /// Sets the upstream information for the branch. /// @@ -74,20 +55,6 @@ public virtual string TrackedBranch } } - /// - /// Set the upstream merge branch directly for this branch. - /// - /// To track the "master" branch on the "origin" remote, set the - /// property to "origin" and the - /// property to "refs/heads/master". - /// - /// - [Obsolete("This property will be removed in the next release. Please use BranchUpdate.UpstreamBranch instead.")] - public virtual string UpstreamMergeBranch - { - set { UpstreamBranch = value; } - } - /// /// Set the upstream branch for this branch. /// @@ -104,20 +71,6 @@ public virtual string UpstreamBranch } } - /// - /// Set the upstream merge branch directly for this branch. - /// - /// To track the "master" branch on the "origin" remote, set the - /// RemoteName property to "origin" and the UpstreamMergeBranch - /// property to "refs/heads/master". - /// - /// - [Obsolete("This property will be removed in the next release. Please use BranchUpdate.Remote instead.")] - public virtual string UpstreamRemote - { - set { Remote = value; } - } - /// /// Set the upstream remote for this branch. /// diff --git a/LibGit2Sharp/CommitLog.cs b/LibGit2Sharp/CommitLog.cs index d6b9a9ebb..9618cd859 100644 --- a/LibGit2Sharp/CommitLog.cs +++ b/LibGit2Sharp/CommitLog.cs @@ -248,7 +248,7 @@ private ObjectId DereferenceToCommit(string identifier) } // TODO: Should we check the type? Git-log allows TagAnnotation oid as parameter. But what about Blobs and Trees? - GitObject commit = repo.Lookup(identifier, Core.GitObjectType.Any, options); + GitObject commit = repo.Lookup(identifier, GitObjectType.Any, options); return commit != null ? commit.Id : null; } diff --git a/LibGit2Sharp/CompareOptions.cs b/LibGit2Sharp/CompareOptions.cs new file mode 100644 index 000000000..c5bee7ed1 --- /dev/null +++ b/LibGit2Sharp/CompareOptions.cs @@ -0,0 +1,29 @@ +namespace LibGit2Sharp +{ + /// + /// Options to define file comparison behavior. + /// + public class CompareOptions + { + /// + /// Initializes a new instance of the class. + /// + public CompareOptions() + { + ContextLines = 3; + InterhunkLines = 0; + } + + /// + /// The number of unchanged lines that define the boundary of a hunk (and to display before and after). + /// (Default = 3) + /// + public int ContextLines { get; set; } + + /// + /// The maximum number of unchanged lines between hunk boundaries before the hunks will be merged into a one. + /// (Default = 0) + /// + public int InterhunkLines { get; set; } + } +} diff --git a/LibGit2Sharp/Core/EnumExtensions.cs b/LibGit2Sharp/Core/EnumExtensions.cs index cef84e775..40d6d4cd4 100644 --- a/LibGit2Sharp/Core/EnumExtensions.cs +++ b/LibGit2Sharp/Core/EnumExtensions.cs @@ -7,7 +7,7 @@ namespace LibGit2Sharp.Core { internal static class EnumExtensions { - public static bool HasAny(this Enum enumInstance, IEnumerable entries) + public static bool HasAny(this Enum enumInstance, IEnumerable entries) { return entries.Any(enumInstance.HasFlag); } diff --git a/LibGit2Sharp/Core/FilePathMarshaler.cs b/LibGit2Sharp/Core/FilePathMarshaler.cs index 93e510fc6..97f81fa2e 100644 --- a/LibGit2Sharp/Core/FilePathMarshaler.cs +++ b/LibGit2Sharp/Core/FilePathMarshaler.cs @@ -1,4 +1,5 @@ using System; +using System.Globalization; using System.Runtime.InteropServices; namespace LibGit2Sharp.Core @@ -10,6 +11,7 @@ namespace LibGit2Sharp.Core /// /// Use this marshaler for return values, for example: /// [return: MarshalAs(UnmanagedType.CustomMarshaler, + /// MarshalCookie = UniqueId.UniqueIdentifier, /// MarshalTypeRef = typeof(FilePathNoCleanupMarshaler))] /// internal class FilePathNoCleanupMarshaler : FilePathMarshaler @@ -41,6 +43,7 @@ public override void CleanUpNativeData(IntPtr pNativeData) /// [DllImport(libgit2)] /// internal static extern int git_index_open(out IndexSafeHandle index, /// [MarshalAs(UnmanagedType.CustomMarshaler, + /// MarshalCookie = UniqueId.UniqueIdentifier, /// MarshalTypeRef = typeof(FilePathMarshaler))] FilePath indexpath); /// internal class FilePathMarshaler : ICustomMarshaler @@ -83,7 +86,14 @@ public IntPtr MarshalManagedToNative(Object managedObj) if (null == filePath) { - throw new MarshalDirectiveException("FilePathMarshaler must be used on a FilePath."); + var expectedType = typeof(FilePath); + var actualType = managedObj.GetType(); + + throw new MarshalDirectiveException( + string.Format(CultureInfo.InvariantCulture, + "FilePathMarshaler must be used on a FilePath. Expected '{0}' from '{1}'; received '{2}' from '{3}'.", + expectedType.FullName, expectedType.Assembly.Location, + actualType.FullName, actualType.Assembly.Location)); } return FromManaged(filePath); diff --git a/LibGit2Sharp/Core/GitObjectType.cs b/LibGit2Sharp/Core/GitObjectType.cs index 083447c88..43fff2445 100644 --- a/LibGit2Sharp/Core/GitObjectType.cs +++ b/LibGit2Sharp/Core/GitObjectType.cs @@ -98,10 +98,5 @@ public static ObjectType ToObjectType(this GitObjectType type) throw new InvalidOperationException(string.Format("Cannot map {0} to a ObjectType.", type)); } } - - public static LibGit2Sharp.GitObjectType ToGitObjectType(this GitObjectType type) - { - return (LibGit2Sharp.GitObjectType)type; - } } } diff --git a/LibGit2Sharp/Core/Handles/GitErrorSafeHandle.cs b/LibGit2Sharp/Core/Handles/GitErrorSafeHandle.cs index 9a222a482..673b2187b 100644 --- a/LibGit2Sharp/Core/Handles/GitErrorSafeHandle.cs +++ b/LibGit2Sharp/Core/Handles/GitErrorSafeHandle.cs @@ -1,3 +1,4 @@ +using System; using System.Runtime.InteropServices; namespace LibGit2Sharp.Core.Handles @@ -6,6 +7,14 @@ internal class GitErrorSafeHandle : NotOwnedSafeHandleBase { public GitError MarshalAsGitError() { + // Required on Mono < 3.0.8 + // https://bugzilla.xamarin.com/show_bug.cgi?id=11417 + // https://github.com/mono/mono/commit/9cdddca7ec283f3b9181f3f69c1acecc0d9cc289 + if (handle == IntPtr.Zero) + { + return null; + } + return (GitError)Marshal.PtrToStructure(handle, typeof(GitError)); } } diff --git a/LibGit2Sharp/Core/NativeDllName.cs b/LibGit2Sharp/Core/NativeDllName.cs new file mode 100644 index 000000000..ec665f71e --- /dev/null +++ b/LibGit2Sharp/Core/NativeDllName.cs @@ -0,0 +1,7 @@ +namespace LibGit2Sharp.Core +{ + internal static class NativeDllName + { + public const string Name = "git2-9d9fff3"; + } +} diff --git a/LibGit2Sharp/Core/NativeMethods.cs b/LibGit2Sharp/Core/NativeMethods.cs index 01cb237c8..7074d95e0 100644 --- a/LibGit2Sharp/Core/NativeMethods.cs +++ b/LibGit2Sharp/Core/NativeMethods.cs @@ -14,7 +14,7 @@ namespace LibGit2Sharp.Core internal static class NativeMethods { public const uint GIT_PATH_MAX = 4096; - private const string libgit2 = "git2"; + private const string libgit2 = NativeDllName.Name; private static readonly LibraryLifetimeObject lifetimeObject; private static int handlesCount; @@ -110,13 +110,13 @@ internal static extern void giterr_set_str( internal static extern int git_blob_create_fromdisk( ref GitOid id, RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path); [DllImport(libgit2)] internal static extern int git_blob_create_fromworkdir( ref GitOid id, RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath relative_path); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath relative_path); internal delegate int source_callback( IntPtr content, @@ -127,7 +127,7 @@ internal delegate int source_callback( internal static extern int git_blob_create_fromchunks( ref GitOid oid, RepositorySafeHandle repositoryPtr, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath hintpath, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath hintpath, source_callback fileCallback, IntPtr data); @@ -141,7 +141,7 @@ internal static extern int git_blob_create_fromchunks( internal static extern int git_branch_create( out ReferenceSafeHandle ref_out, RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string branch_name, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string branch_name, GitObjectSafeHandle target, // TODO: GitCommitSafeHandle? [MarshalAs(UnmanagedType.Bool)] bool force); @@ -165,7 +165,7 @@ internal static extern int git_branch_foreach( 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.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string new_branch_name, [MarshalAs(UnmanagedType.Bool)] bool force); [DllImport(libgit2)] @@ -173,14 +173,14 @@ internal static extern int git_branch_remote_name( byte[] remote_name_out, UIntPtr buffer_size, RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string canonical_branch_name); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string canonical_branch_name); [DllImport(libgit2)] internal static extern int git_branch_upstream_name( byte[] tracking_branch_name_out, // NB: This is more properly a StringBuilder, but it's UTF8 UIntPtr buffer_size, RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string referenceName); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string referenceName); [DllImport(libgit2)] internal static extern int git_checkout_tree( @@ -197,8 +197,8 @@ internal static extern int git_checkout_index( [DllImport(libgit2)] internal static extern int git_clone( out RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string origin_url, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath workdir_path, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string origin_url, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath workdir_path, GitCloneOptions opts); [DllImport(libgit2)] @@ -211,21 +211,21 @@ internal static extern int git_clone( internal static extern int git_commit_create( out GitOid id, RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string updateRef, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string updateRef, SignatureSafeHandle author, SignatureSafeHandle committer, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string encoding, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string message, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string encoding, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string message, GitObjectSafeHandle tree, int parentCount, - [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 7)] [In] IntPtr[] parents); + [MarshalAs(UnmanagedType.LPArray)] [In] IntPtr[] parents); [DllImport(libgit2)] - [return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] + [return : MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] internal static extern string git_commit_message(GitObjectSafeHandle commit); [DllImport(libgit2)] - [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] internal static extern string git_commit_message_encoding(GitObjectSafeHandle commit); [DllImport(libgit2)] @@ -256,12 +256,12 @@ internal static extern int git_commit_create( internal static extern int git_config_get_entry( out GitConfigEntryHandle entry, ConfigurationSafeHandle cfg, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string name); [DllImport(libgit2)] internal static extern int git_config_add_file_ondisk( ConfigurationSafeHandle cfg, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path, uint level, bool force); @@ -277,41 +277,41 @@ internal static extern int git_config_open_level( [DllImport(libgit2)] internal static extern int git_config_parse_bool( [MarshalAs(UnmanagedType.Bool)] out bool value, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string valueToParse); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string valueToParse); [DllImport(libgit2)] internal static extern int git_config_parse_int32( [MarshalAs(UnmanagedType.I4)] out int value, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string valueToParse); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string valueToParse); [DllImport(libgit2)] internal static extern int git_config_parse_int64( [MarshalAs(UnmanagedType.I8)] out long value, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string valueToParse); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string valueToParse); [DllImport(libgit2)] internal static extern int git_config_set_bool( ConfigurationSafeHandle cfg, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string name, [MarshalAs(UnmanagedType.Bool)] bool value); [DllImport(libgit2)] internal static extern int git_config_set_int32( ConfigurationSafeHandle cfg, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string name, int value); [DllImport(libgit2)] internal static extern int git_config_set_int64( ConfigurationSafeHandle cfg, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string name, long value); [DllImport(libgit2)] internal static extern int git_config_set_string( ConfigurationSafeHandle cfg, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string value); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string name, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string value); internal delegate int config_foreach_callback( IntPtr entry, @@ -338,8 +338,8 @@ internal delegate int git_cred_acquire_cb( [DllImport(libgit2)] internal static extern int git_cred_userpass_plaintext_new( out IntPtr cred, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof (Utf8Marshaler))] string username, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof (Utf8Marshaler))] string password); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof (Utf8Marshaler))] string username, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof (Utf8Marshaler))] string password); [DllImport(libgit2)] internal static extern void git_diff_list_free(IntPtr diff); @@ -429,7 +429,7 @@ internal static extern int git_diff_foreach( [DllImport(libgit2)] internal static extern int git_ignore_add_rule( RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof (Utf8Marshaler))] string rules); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof (Utf8Marshaler))] string rules); [DllImport(libgit2)] internal static extern int git_ignore_clear_internal_rules(RepositorySafeHandle repo); @@ -438,12 +438,12 @@ internal static extern int git_ignore_add_rule( internal static extern int git_ignore_path_is_ignored( out int ignored, RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path); [DllImport(libgit2)] internal static extern int git_index_add_bypath( IndexSafeHandle index, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path); [DllImport(libgit2)] internal static extern int git_index_add( @@ -456,7 +456,7 @@ internal static extern int git_index_conflict_get( out IndexEntrySafeHandle ours, out IndexEntrySafeHandle theirs, IndexSafeHandle index, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path); [DllImport(libgit2)] internal static extern UIntPtr git_index_entrycount(IndexSafeHandle index); @@ -468,7 +468,7 @@ internal static extern int git_index_conflict_get( internal static extern int git_index_find( out UIntPtr pos, IndexSafeHandle index, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path); [DllImport(libgit2)] internal static extern void git_index_free(IntPtr index); @@ -479,7 +479,7 @@ internal static extern int git_index_find( [DllImport(libgit2)] internal static extern IndexEntrySafeHandle git_index_get_bypath( IndexSafeHandle index, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path, int stage); [DllImport(libgit2)] @@ -488,12 +488,12 @@ internal static extern IndexEntrySafeHandle git_index_get_bypath( [DllImport(libgit2)] internal static extern int git_index_open( out IndexSafeHandle index, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath indexpath); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath indexpath); [DllImport(libgit2)] internal static extern int git_index_remove_bypath( IndexSafeHandle index, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path); [DllImport(libgit2)] internal static extern int git_index_write(IndexSafeHandle index); @@ -512,7 +512,7 @@ internal static extern int git_merge_base( internal static extern int git_message_prettify( byte[] message_out, // NB: This is more properly a StringBuilder, but it's UTF8 UIntPtr buffer_size, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string message, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string message, bool strip_comments); [DllImport(libgit2)] @@ -521,16 +521,16 @@ internal static extern int git_note_create( RepositorySafeHandle repo, SignatureSafeHandle author, SignatureSafeHandle committer, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string notes_ref, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string notes_ref, ref GitOid oid, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string note, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string note, int force); [DllImport(libgit2)] internal static extern void git_note_free(IntPtr note); [DllImport(libgit2)] - [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] internal static extern string git_note_message(NoteSafeHandle note); [DllImport(libgit2)] @@ -540,20 +540,20 @@ internal static extern int git_note_create( internal static extern int git_note_read( out NoteSafeHandle note, RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string notes_ref, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string notes_ref, ref GitOid oid); [DllImport(libgit2)] internal static extern int git_note_remove( RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string notes_ref, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string notes_ref, SignatureSafeHandle author, SignatureSafeHandle committer, ref GitOid oid); [DllImport(libgit2)] internal static extern int git_note_default_ref( - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] out string notes_ref, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] out string notes_ref, RepositorySafeHandle repo); internal delegate int git_note_foreach_cb( @@ -564,7 +564,7 @@ internal delegate int git_note_foreach_cb( [DllImport(libgit2)] internal static extern int git_note_foreach( RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string notes_ref, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string notes_ref, git_note_foreach_cb cb, IntPtr payload); @@ -604,7 +604,7 @@ internal static extern int git_object_peel( [DllImport(libgit2)] internal static extern int git_push_add_refspec( PushSafeHandle push, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string pushRefSpec); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string pushRefSpec); [DllImport(libgit2)] internal static extern int git_push_finish(PushSafeHandle push); @@ -633,7 +633,7 @@ internal delegate int push_status_foreach_cb( internal static extern int git_reference_create( out ReferenceSafeHandle reference, RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string name, ref GitOid oid, [MarshalAs(UnmanagedType.Bool)] bool force); @@ -641,8 +641,8 @@ internal static extern int git_reference_create( internal static extern int git_reference_symbolic_create( out ReferenceSafeHandle reference, RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string target, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string name, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string target, [MarshalAs(UnmanagedType.Bool)] bool force); [DllImport(libgit2)] @@ -655,8 +655,7 @@ internal delegate int ref_glob_callback( [DllImport(libgit2)] internal static extern int git_reference_foreach_glob( RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string glob, - GitReferenceType flags, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string glob, ref_glob_callback callback, IntPtr payload); @@ -665,16 +664,16 @@ internal static extern int git_reference_foreach_glob( [DllImport(libgit2)] internal static extern int git_reference_is_valid_name( - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string refname); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string refname); [DllImport(libgit2)] internal static extern int git_reference_lookup( out ReferenceSafeHandle reference, RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string name); [DllImport(libgit2)] - [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] internal static extern string git_reference_name(ReferenceSafeHandle reference); [DllImport(libgit2)] @@ -684,7 +683,7 @@ internal static extern int git_reference_lookup( internal static extern int git_reference_rename( out ReferenceSafeHandle ref_out, ReferenceSafeHandle reference, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string newName, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string newName, [MarshalAs(UnmanagedType.Bool)] bool force); [DllImport(libgit2)] @@ -697,10 +696,10 @@ internal static extern int git_reference_rename( internal static extern int git_reference_symbolic_set_target( out ReferenceSafeHandle ref_out, ReferenceSafeHandle reference, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string target); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string target); [DllImport(libgit2)] - [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] internal static extern string git_reference_symbolic_target(ReferenceSafeHandle reference); [DllImport(libgit2)] @@ -741,13 +740,13 @@ internal static extern int git_reflog_append( ReflogSafeHandle reflog, ref GitOid id, SignatureSafeHandle committer, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string msg); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string msg); [DllImport(libgit2)] internal static extern int git_reflog_write(ReflogSafeHandle reflog); [DllImport(libgit2)] - [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] internal static extern string git_reflog_entry_message(SafeHandle entry); [DllImport(libgit2)] @@ -755,7 +754,7 @@ internal static extern int git_refspec_rtransform( byte[] target, UIntPtr outlen, GitRefSpecHandle refSpec, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string name); [DllImport(libgit2)] internal static extern int git_remote_connect(RemoteSafeHandle remote, GitDirection direction); @@ -764,8 +763,8 @@ internal static extern int git_refspec_rtransform( internal static extern int git_remote_create( out RemoteSafeHandle remote, RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string url); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string name, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string url); [DllImport(libgit2)] internal static extern void git_remote_disconnect(RemoteSafeHandle remote); @@ -784,13 +783,13 @@ internal static extern int git_remote_download( [DllImport(libgit2)] internal static extern int git_remote_is_valid_name( - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string remote_name); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string remote_name); [DllImport(libgit2)] internal static extern int git_remote_load( out RemoteSafeHandle remote, RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string name); internal delegate int git_headlist_cb(ref GitRemoteHead remoteHeadPtr, IntPtr payload); @@ -798,7 +797,7 @@ internal static extern int git_remote_load( internal static extern int git_remote_ls(RemoteSafeHandle remote, git_headlist_cb headlist_cb, IntPtr payload); [DllImport(libgit2)] - [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] internal static extern string git_remote_name(RemoteSafeHandle remote); [DllImport(libgit2)] @@ -811,7 +810,7 @@ internal static extern void git_remote_set_cred_acquire_cb( IntPtr payload); [DllImport(libgit2)] - [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] internal static extern string git_remote_url(RemoteSafeHandle remote); [DllImport(libgit2)] @@ -825,7 +824,7 @@ internal static extern int git_remote_set_callbacks( [DllImport(libgit2)] internal static extern int git_remote_add_fetch( RemoteSafeHandle remote, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof (Utf8Marshaler))] string refspec); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof (Utf8Marshaler))] string refspec); internal delegate void remote_progress_callback(IntPtr str, int len, IntPtr data); @@ -844,9 +843,9 @@ internal delegate int remote_update_tips_callback( internal static extern int git_repository_discover( byte[] repository_path, // NB: This is more properly a StringBuilder, but it's UTF8 UIntPtr size, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath start_path, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath start_path, [MarshalAs(UnmanagedType.Bool)] bool across_fs, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath ceiling_dirs); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath ceiling_dirs); internal delegate int git_repository_fetchhead_foreach_cb( IntPtr remote_name, @@ -876,7 +875,7 @@ internal static extern int git_repository_fetchhead_foreach( [DllImport(libgit2)] internal static extern int git_repository_init( out RepositorySafeHandle repository, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path, [MarshalAs(UnmanagedType.Bool)] bool isBare); [DllImport(libgit2)] @@ -885,6 +884,9 @@ internal static extern int git_repository_init( [DllImport(libgit2)] internal static extern int git_repository_is_empty(RepositorySafeHandle repo); + [DllImport(libgit2)] + internal static extern int git_repository_is_shallow(RepositorySafeHandle repo); + [DllImport(libgit2)] internal static extern int git_repository_merge_cleanup(RepositorySafeHandle repo); @@ -910,17 +912,17 @@ internal static extern int git_repository_message( [DllImport(libgit2)] internal static extern int git_repository_open( out RepositorySafeHandle repository, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path); [DllImport(libgit2)] internal static extern int git_repository_open_ext( NullRepositorySafeHandle repository, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path, RepositoryOpenFlags flags, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath ceilingDirs); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath ceilingDirs); [DllImport(libgit2)] - [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathNoCleanupMarshaler))] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathNoCleanupMarshaler))] internal static extern FilePath git_repository_path(RepositorySafeHandle repository); [DllImport(libgit2)] @@ -936,7 +938,7 @@ internal static extern void git_repository_set_index( [DllImport(libgit2)] internal static extern int git_repository_set_workdir( RepositorySafeHandle repository, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath workdir, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath workdir, bool update_gitlink); [DllImport(libgit2)] @@ -944,7 +946,7 @@ internal static extern int git_repository_state( RepositorySafeHandle repository); [DllImport(libgit2)] - [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathNoCleanupMarshaler))] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathNoCleanupMarshaler))] internal static extern FilePath git_repository_workdir(RepositorySafeHandle repository); [DllImport(libgit2)] @@ -957,7 +959,7 @@ internal static extern int git_reset( internal static extern int git_revparse_single( out GitObjectSafeHandle obj, RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string spec); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string spec); [DllImport(libgit2)] internal static extern void git_revwalk_free(IntPtr walker); @@ -986,8 +988,8 @@ internal static extern int git_revparse_single( [DllImport(libgit2)] internal static extern int git_signature_new( out SignatureSafeHandle signature, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string email, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string name, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string email, long time, int offset); @@ -996,7 +998,7 @@ internal static extern int git_stash_save( out GitOid id, RepositorySafeHandle repo, SignatureSafeHandle stasher, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string message, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string message, StashOptions flags); internal delegate int git_stash_cb( @@ -1018,7 +1020,7 @@ internal static extern int git_stash_foreach( internal static extern int git_status_file( out FileStatus statusflags, RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath filepath); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath filepath); internal delegate int git_status_cb( IntPtr path, @@ -1032,7 +1034,7 @@ internal delegate int git_status_cb( internal static extern int git_submodule_lookup( out SubmoduleSafeHandle reference, RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string name); internal delegate int submodule_callback( IntPtr sm, @@ -1055,12 +1057,12 @@ internal static extern int git_submodule_save( SubmoduleSafeHandle submodule); [DllImport(libgit2)] - [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] internal static extern string git_submodule_path( SubmoduleSafeHandle submodule); [DllImport(libgit2)] - [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] internal static extern string git_submodule_url( SubmoduleSafeHandle submodule); @@ -1097,14 +1099,23 @@ internal static extern int git_submodule_status( out SubmoduleStatus status, SubmoduleSafeHandle submodule); + [DllImport(libgit2)] + internal static extern int git_tag_annotation_create( + out GitOid oid, + RepositorySafeHandle repo, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string name, + GitObjectSafeHandle target, + SignatureSafeHandle signature, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string message); + [DllImport(libgit2)] internal static extern int git_tag_create( out GitOid oid, RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string name, GitObjectSafeHandle target, SignatureSafeHandle signature, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string message, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string message, [MarshalAs(UnmanagedType.Bool)] bool force); @@ -1112,7 +1123,7 @@ internal static extern int git_tag_create( internal static extern int git_tag_create_lightweight( out GitOid oid, RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string name, GitObjectSafeHandle target, [MarshalAs(UnmanagedType.Bool)] bool force); @@ -1120,14 +1131,14 @@ internal static extern int git_tag_create_lightweight( [DllImport(libgit2)] internal static extern int git_tag_delete( RepositorySafeHandle repo, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string tagName); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string tagName); [DllImport(libgit2)] - [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] internal static extern string git_tag_message(GitObjectSafeHandle tag); [DllImport(libgit2)] - [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] internal static extern string git_tag_name(GitObjectSafeHandle tag); [DllImport(libgit2)] @@ -1157,7 +1168,7 @@ internal static extern int git_tag_delete( internal static extern int git_tree_entry_bypath( out TreeEntrySafeHandle_Owned tree, GitObjectSafeHandle root, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath treeentry_path); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath treeentry_path); [DllImport(libgit2)] internal static extern void git_tree_entry_free(IntPtr treeEntry); @@ -1166,7 +1177,7 @@ internal static extern int git_tree_entry_bypath( internal static extern OidSafeHandle git_tree_entry_id(SafeHandle entry); [DllImport(libgit2)] - [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] internal static extern string git_tree_entry_name(SafeHandle entry); [DllImport(libgit2)] @@ -1182,7 +1193,7 @@ internal static extern int git_tree_entry_bypath( internal static extern int git_treebuilder_insert( IntPtr entry_out, TreeBuilderSafeHandle builder, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string treeentry_name, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(Utf8Marshaler))] string treeentry_name, ref GitOid id, uint attributes); diff --git a/LibGit2Sharp/Core/Proxy.cs b/LibGit2Sharp/Core/Proxy.cs index b1ddf84f1..d9ebbacc6 100644 --- a/LibGit2Sharp/Core/Proxy.cs +++ b/LibGit2Sharp/Core/Proxy.cs @@ -1151,10 +1151,9 @@ public static void git_reference_delete(ReferenceSafeHandle reference) public static ICollection git_reference_foreach_glob( RepositorySafeHandle repo, string glob, - GitReferenceType flags, Func resultSelector) { - return git_foreach(resultSelector, c => NativeMethods.git_reference_foreach_glob(repo, glob, flags, (x, p) => c(x, p), IntPtr.Zero)); + return git_foreach(resultSelector, c => NativeMethods.git_reference_foreach_glob(repo, glob, (x, p) => c(x, p), IntPtr.Zero)); } public static void git_reference_free(IntPtr reference) @@ -1170,12 +1169,12 @@ public static bool git_reference_is_valid_name(string refname) return (res == 1); } - public static IList git_reference_list(RepositorySafeHandle repo, GitReferenceType flags) + public static IList git_reference_list(RepositorySafeHandle repo) { using (ThreadAffinity()) { UnSafeNativeMethods.git_strarray arr; - int res = UnSafeNativeMethods.git_reference_list(out arr, repo, flags); + int res = UnSafeNativeMethods.git_reference_list(out arr, repo); Ensure.ZeroResult(res); return Libgit2UnsafeHelper.BuildListOf(arr); @@ -1592,6 +1591,11 @@ public static bool git_repository_is_empty(RepositorySafeHandle repo) return RepositoryStateChecker(repo, NativeMethods.git_repository_is_empty); } + public static bool git_repository_is_shallow(RepositorySafeHandle repo) + { + return RepositoryStateChecker(repo, NativeMethods.git_repository_is_shallow); + } + public static void git_repository_merge_cleanup(RepositorySafeHandle repo) { using (ThreadAffinity()) @@ -2059,6 +2063,25 @@ public static SubmoduleStatus git_submodule_status(SubmoduleSafeHandle submodule #region git_tag_ + public static ObjectId git_tag_annotation_create( + RepositorySafeHandle repo, + string name, + GitObject target, + Signature tagger, + string message) + { + using (ThreadAffinity()) + using (var objectPtr = new ObjectSafeWrapper(target.Id, repo)) + using (SignatureSafeHandle taggerHandle = tagger.BuildHandle()) + { + GitOid oid; + int res = NativeMethods.git_tag_annotation_create(out oid, repo, name, objectPtr.ObjectPtr, taggerHandle, message); + Ensure.ZeroResult(res); + + return oid; + } + } + public static ObjectId git_tag_create( RepositorySafeHandle repo, string name, diff --git a/LibGit2Sharp/Core/UnSafeNativeMethods.cs b/LibGit2Sharp/Core/UnSafeNativeMethods.cs index 49093e6e3..3d692d9d9 100644 --- a/LibGit2Sharp/Core/UnSafeNativeMethods.cs +++ b/LibGit2Sharp/Core/UnSafeNativeMethods.cs @@ -6,10 +6,10 @@ namespace LibGit2Sharp.Core { internal static unsafe class UnSafeNativeMethods { - private const string libgit2 = "git2"; + private const string libgit2 = NativeDllName.Name; [DllImport(libgit2)] - internal static extern int git_reference_list(out git_strarray array, RepositorySafeHandle repo, GitReferenceType flags); + internal static extern int git_reference_list(out git_strarray array, RepositorySafeHandle repo); [DllImport(libgit2)] internal static extern int git_remote_list(out git_strarray array, RepositorySafeHandle repo); diff --git a/LibGit2Sharp/Core/Utf8Marshaler.cs b/LibGit2Sharp/Core/Utf8Marshaler.cs index ec78db8fc..79fd2a6c4 100644 --- a/LibGit2Sharp/Core/Utf8Marshaler.cs +++ b/LibGit2Sharp/Core/Utf8Marshaler.cs @@ -11,6 +11,7 @@ namespace LibGit2Sharp.Core /// /// Use this marshaler for return values, for example: /// [return: MarshalAs(UnmanagedType.CustomMarshaler, + /// MarshalCookie = UniqueId.UniqueIdentifier, /// MarshalTypeRef = typeof(Utf8NoCleanupMarshaler))] /// internal class Utf8NoCleanupMarshaler : Utf8Marshaler @@ -42,6 +43,7 @@ public override void CleanUpNativeData(IntPtr pNativeData) /// [DllImport(libgit2)] /// internal static extern int git_tag_delete(RepositorySafeHandle repo, /// [MarshalAs(UnmanagedType.CustomMarshaler, + /// MarshalCookie = UniqueId.UniqueIdentifier, /// MarshalTypeRef = typeof(Utf8Marshaler))] String tagName); /// internal class Utf8Marshaler : ICustomMarshaler diff --git a/LibGit2Sharp/Diff.cs b/LibGit2Sharp/Diff.cs index a14071935..c5e1f12ea 100644 --- a/LibGit2Sharp/Diff.cs +++ b/LibGit2Sharp/Diff.cs @@ -19,12 +19,15 @@ public class Diff { private readonly Repository repo; - private static GitDiffOptions BuildOptions(DiffOptions diffOptions, FilePath[] filePaths = null, MatchedPathsAggregator matchedPathsAggregator = null) + private static GitDiffOptions BuildOptions(DiffOptions diffOptions, FilePath[] filePaths = null, MatchedPathsAggregator matchedPathsAggregator = null, CompareOptions compareOptions = null) { var options = new GitDiffOptions(); options.Flags |= GitDiffOptionFlags.GIT_DIFF_INCLUDE_TYPECHANGE; - options.ContextLines = 3; + + compareOptions = compareOptions ?? new CompareOptions(); + options.ContextLines = (ushort)compareOptions.ContextLines; + options.InterhunkLines = (ushort)compareOptions.InterhunkLines; if (diffOptions.HasFlag(DiffOptions.IncludeUntracked)) { @@ -110,8 +113,9 @@ internal Diff(Repository repo) /// If set, the passed will be treated as explicit paths. /// Use these options to determine how unmatched explicit paths should be handled. /// + /// Additional options to define comparison behavior. /// A containing the changes between the and the . - public virtual TreeChanges Compare(Tree oldTree, Tree newTree, IEnumerable paths = null, ExplicitPathsOptions explicitPathsOptions = null) + public virtual TreeChanges Compare(Tree oldTree, Tree newTree, IEnumerable paths = null, ExplicitPathsOptions explicitPathsOptions = null, CompareOptions compareOptions = null) { var comparer = TreeToTree(repo); ObjectId oldTreeId = oldTree != null ? oldTree.Id : null; @@ -129,7 +133,7 @@ public virtual TreeChanges Compare(Tree oldTree, Tree newTree, IEnumerable @@ -137,10 +141,11 @@ public virtual TreeChanges Compare(Tree oldTree, Tree newTree, IEnumerable /// The you want to compare from. /// The you want to compare to. + /// Additional options to define comparison behavior. /// A containing the changes between the and the . - public virtual ContentChanges Compare(Blob oldBlob, Blob newBlob) + public virtual ContentChanges Compare(Blob oldBlob, Blob newBlob, CompareOptions compareOptions = null) { - using (GitDiffOptions options = BuildOptions(DiffOptions.None)) + using (GitDiffOptions options = BuildOptions(DiffOptions.None, compareOptions: compareOptions)) { return new ContentChanges(repo, oldBlob, newBlob, options); } @@ -168,8 +173,9 @@ private static IDictionary will be treated as explicit paths. /// Use these options to determine how unmatched explicit paths should be handled. /// + /// Additional options to define comparison behavior. /// A containing the changes between the and the selected target. - public virtual TreeChanges Compare(Tree oldTree, DiffTargets diffTargets, IEnumerable paths = null, ExplicitPathsOptions explicitPathsOptions = null) + public virtual TreeChanges Compare(Tree oldTree, DiffTargets diffTargets, IEnumerable paths = null, ExplicitPathsOptions explicitPathsOptions = null, CompareOptions compareOptions = null) { var comparer = handleRetrieverDispatcher[diffTargets](repo); ObjectId oldTreeId = oldTree != null ? oldTree.Id : null; @@ -188,7 +194,7 @@ public virtual TreeChanges Compare(Tree oldTree, DiffTargets diffTargets, IEnume } } - return BuildTreeChangesFromComparer(oldTreeId, null, comparer, diffOptions, paths, explicitPathsOptions); + return BuildTreeChangesFromComparer(oldTreeId, null, comparer, diffOptions, paths, explicitPathsOptions, compareOptions); } /// @@ -200,14 +206,15 @@ public virtual TreeChanges Compare(Tree oldTree, DiffTargets diffTargets, IEnume /// If set, the passed will be treated as explicit paths. /// Use these options to determine how unmatched explicit paths should be handled. /// + /// Additional options to define comparison behavior. /// A containing the changes between the working directory and the index. - public virtual TreeChanges Compare(IEnumerable paths = null, bool includeUntracked = false, ExplicitPathsOptions explicitPathsOptions = null) + public virtual TreeChanges Compare(IEnumerable paths = null, bool includeUntracked = false, ExplicitPathsOptions explicitPathsOptions = null, CompareOptions compareOptions = null) { - return Compare(includeUntracked ? DiffOptions.IncludeUntracked : DiffOptions.None, paths, explicitPathsOptions); + return Compare(includeUntracked ? DiffOptions.IncludeUntracked : DiffOptions.None, paths, explicitPathsOptions, compareOptions); } internal virtual TreeChanges Compare(DiffOptions diffOptions, IEnumerable paths = null, - ExplicitPathsOptions explicitPathsOptions = null) + ExplicitPathsOptions explicitPathsOptions = null, CompareOptions compareOptions = null) { var comparer = WorkdirToIndex(repo); @@ -222,7 +229,7 @@ internal virtual TreeChanges Compare(DiffOptions diffOptions, IEnumerable paths = null, ExplicitPathsOptions explicitPathsOptions = null) + DiffOptions diffOptions, IEnumerable paths = null, ExplicitPathsOptions explicitPathsOptions = null, CompareOptions compareOptions = null) { var matchedPaths = new MatchedPathsAggregator(); var filePaths = ToFilePaths(repo, paths); - using (GitDiffOptions options = BuildOptions(diffOptions, filePaths, matchedPaths)) + using (GitDiffOptions options = BuildOptions(diffOptions, filePaths, matchedPaths, compareOptions)) using (DiffListSafeHandle diffList = comparisonHandleRetriever(oldTreeId, newTreeId, options)) { if (explicitPathsOptions != null) diff --git a/LibGit2Sharp/GitObject.cs b/LibGit2Sharp/GitObject.cs index a61892c4a..a595f931a 100644 --- a/LibGit2Sharp/GitObject.cs +++ b/LibGit2Sharp/GitObject.cs @@ -60,17 +60,17 @@ public virtual string Sha get { return Id.Sha; } } - internal static GitObject BuildFrom(Repository repo, ObjectId id, Core.GitObjectType type, FilePath path) + internal static GitObject BuildFrom(Repository repo, ObjectId id, GitObjectType type, FilePath path) { switch (type) { - case Core.GitObjectType.Commit: + case GitObjectType.Commit: return new Commit(repo, id); - case Core.GitObjectType.Tree: + case GitObjectType.Tree: return new Tree(repo, id, path); - case Core.GitObjectType.Tag: + case GitObjectType.Tag: return new TagAnnotation(repo, id); - case Core.GitObjectType.Blob: + case GitObjectType.Blob: return new Blob(repo, id); default: throw new LibGit2SharpException(string.Format(CultureInfo.InvariantCulture, "Unexpected type '{0}' for object '{1}'.", type, id)); @@ -79,14 +79,14 @@ internal static GitObject BuildFrom(Repository repo, ObjectId id, Core.GitObject internal Commit DereferenceToCommit(bool throwsIfCanNotBeDereferencedToACommit) { - using (GitObjectSafeHandle peeledHandle = Proxy.git_object_peel(repo.Handle, Id, Core.GitObjectType.Commit, throwsIfCanNotBeDereferencedToACommit)) + using (GitObjectSafeHandle peeledHandle = Proxy.git_object_peel(repo.Handle, Id, GitObjectType.Commit, throwsIfCanNotBeDereferencedToACommit)) { if (peeledHandle == null) { return null; } - return (Commit)BuildFrom(repo, Proxy.git_object_id(peeledHandle), Core.GitObjectType.Commit, null); + return (Commit)BuildFrom(repo, Proxy.git_object_id(peeledHandle), GitObjectType.Commit, null); } } diff --git a/LibGit2Sharp/GitObjectType.cs b/LibGit2Sharp/GitObjectType.cs deleted file mode 100644 index 70cc88e62..000000000 --- a/LibGit2Sharp/GitObjectType.cs +++ /dev/null @@ -1,69 +0,0 @@ -using System; - -namespace LibGit2Sharp -{ - /// - /// Underlying type of a - /// - [Obsolete("This type will be removed in the next release.")] - public enum GitObjectType - { - /// - /// Object can be of any type. - /// - Any = -2, - - /// - /// Object is invalid. - /// - Bad = -1, - - /// - /// Reserved for future use. - /// - Ext1 = 0, - - /// - /// A commit object. - /// - Commit = 1, - - /// - /// A tree (directory listing) object. - /// - Tree = 2, - - /// - /// A file revision object. - /// - Blob = 3, - - /// - /// An annotated tag object. - /// - Tag = 4, - - /// - /// Reserved for future use. - /// - Ext2 = 5, - - /// - /// A delta, base is given by an offset. - /// - OfsDelta = 6, - - /// - /// A delta, base is given by object id. - /// - RefDelta = 7 - } - - internal static class GitObjectTypeExtensions - { - public static Core.GitObjectType ToCoreGitObjectType(this GitObjectType type) - { - return (Core.GitObjectType)type; - } - } -} diff --git a/LibGit2Sharp/IRepository.cs b/LibGit2Sharp/IRepository.cs index 7065b2615..f1acef0d5 100644 --- a/LibGit2Sharp/IRepository.cs +++ b/LibGit2Sharp/IRepository.cs @@ -89,24 +89,6 @@ public interface IRepository : IDisposable /// The new HEAD. Branch Checkout(string committishOrBranchSpec, CheckoutOptions checkoutOptions, CheckoutProgressHandler onCheckoutProgress); - /// - /// Try to lookup an object by its and . If no matching object is found, null will be returned. - /// - /// The id to lookup. - /// The kind of GitObject being looked up - /// The or null if it was not found. - [Obsolete("This method will be removed in the next release. Please use another Repository.Lookup() overload instead.")] - GitObject Lookup(ObjectId id, GitObjectType type = GitObjectType.Any); - - /// - /// Try to lookup an object by its sha or a reference canonical name and . If no matching object is found, null will be returned. - /// - /// A revparse spec for the object to lookup. - /// The kind of being looked up - /// The or null if it was not found. - [Obsolete("This method will be removed in the next release. Please use another Repository.Lookup() overload instead.")] - GitObject Lookup(string objectish, GitObjectType type = GitObjectType.Any); - /// /// Try to lookup an object by its . If no matching object is found, null will be returned. /// diff --git a/LibGit2Sharp/Index.cs b/LibGit2Sharp/Index.cs index 094e51573..4ab480992 100644 --- a/LibGit2Sharp/Index.cs +++ b/LibGit2Sharp/Index.cs @@ -268,13 +268,13 @@ public virtual void Move(IEnumerable sourcePaths, IEnumerable de } FileStatus sourceStatus = keyValuePair.Key.Item2; - if (sourceStatus.HasAny(new[] { FileStatus.Nonexistent, FileStatus.Removed, FileStatus.Untracked, FileStatus.Missing })) + if (sourceStatus.HasAny(new Enum[] { FileStatus.Nonexistent, FileStatus.Removed, FileStatus.Untracked, FileStatus.Missing })) { throw new LibGit2SharpException(string.Format(CultureInfo.InvariantCulture, "Unable to move file '{0}'. Its current status is '{1}'.", sourcePath, sourceStatus)); } FileStatus desStatus = keyValuePair.Value.Item2; - if (desStatus.HasAny(new[] { FileStatus.Nonexistent, FileStatus.Missing })) + if (desStatus.HasAny(new Enum[] { FileStatus.Nonexistent, FileStatus.Missing })) { continue; } diff --git a/LibGit2Sharp/LibGit2Sharp.csproj b/LibGit2Sharp/LibGit2Sharp.csproj index d36959ac7..0da4df39c 100644 --- a/LibGit2Sharp/LibGit2Sharp.csproj +++ b/LibGit2Sharp/LibGit2Sharp.csproj @@ -67,7 +67,10 @@ + + + @@ -206,7 +209,6 @@ - @@ -260,6 +262,7 @@ + diff --git a/LibGit2Sharp/ObjectDatabase.cs b/LibGit2Sharp/ObjectDatabase.cs index 7db7502be..8b4795f19 100644 --- a/LibGit2Sharp/ObjectDatabase.cs +++ b/LibGit2Sharp/ObjectDatabase.cs @@ -159,5 +159,22 @@ internal Commit CreateCommit(string message, Signature author, Signature committ return repo.Lookup(commitId); } + + /// + /// Inserts a into the object database, pointing to a specific . + /// + /// The name. + /// The being pointed at. + /// The tagger. + /// The message. + /// The created . + public virtual TagAnnotation CreateTag(string name, GitObject target, Signature tagger, string message) + { + string prettifiedMessage = Proxy.git_message_prettify(message); + + ObjectId tagId = Proxy.git_tag_annotation_create(repo.Handle, name, target, tagger, prettifiedMessage); + + return repo.Lookup(tagId); + } } } diff --git a/LibGit2Sharp/ObjectType.cs b/LibGit2Sharp/ObjectType.cs index c23a6046a..ac8402f6f 100644 --- a/LibGit2Sharp/ObjectType.cs +++ b/LibGit2Sharp/ObjectType.cs @@ -1,4 +1,5 @@ using System; +using LibGit2Sharp.Core; namespace LibGit2Sharp { @@ -30,21 +31,21 @@ public enum ObjectType internal static class ObjectTypeExtensions { - public static Core.GitObjectType ToGitObjectType(this ObjectType type) + public static GitObjectType ToGitObjectType(this ObjectType type) { switch (type) { case ObjectType.Commit: - return Core.GitObjectType.Commit; + return GitObjectType.Commit; case ObjectType.Tree: - return Core.GitObjectType.Tree; + return GitObjectType.Tree; case ObjectType.Blob: - return Core.GitObjectType.Blob; + return GitObjectType.Blob; case ObjectType.Tag: - return Core.GitObjectType.Tag; + return GitObjectType.Tag; default: throw new InvalidOperationException(string.Format("Cannot map {0} to a GitObjectType.", type)); diff --git a/LibGit2Sharp/OdbBackend.cs b/LibGit2Sharp/OdbBackend.cs index cf76cdced..5a2048690 100644 --- a/LibGit2Sharp/OdbBackend.cs +++ b/LibGit2Sharp/OdbBackend.cs @@ -197,13 +197,13 @@ private static class BackendEntryPoints private unsafe static int Read( out IntPtr buffer_p, out UIntPtr len_p, - out Core.GitObjectType type_p, + out GitObjectType type_p, IntPtr backend, ref GitOid oid) { buffer_p = IntPtr.Zero; len_p = UIntPtr.Zero; - type_p = Core.GitObjectType.Bad; + type_p = GitObjectType.Bad; OdbBackend odbBackend = GCHandle.FromIntPtr(Marshal.ReadIntPtr(backend, GitOdbBackend.GCHandleOffset)).Target as OdbBackend; @@ -255,7 +255,7 @@ private unsafe static int ReadPrefix( out GitOid out_oid, out IntPtr buffer_p, out UIntPtr len_p, - out Core.GitObjectType type_p, + out GitObjectType type_p, IntPtr backend, ref GitOid short_oid, UIntPtr len) @@ -263,7 +263,7 @@ private unsafe static int ReadPrefix( out_oid = default(GitOid); buffer_p = IntPtr.Zero; len_p = UIntPtr.Zero; - type_p = Core.GitObjectType.Bad; + type_p = GitObjectType.Bad; OdbBackend odbBackend = GCHandle.FromIntPtr(Marshal.ReadIntPtr(backend, GitOdbBackend.GCHandleOffset)).Target as OdbBackend; @@ -320,12 +320,12 @@ private unsafe static int ReadPrefix( private static int ReadHeader( out UIntPtr len_p, - out Core.GitObjectType type_p, + out GitObjectType type_p, IntPtr backend, ref GitOid oid) { len_p = UIntPtr.Zero; - type_p = Core.GitObjectType.Bad; + type_p = GitObjectType.Bad; OdbBackend odbBackend = GCHandle.FromIntPtr(Marshal.ReadIntPtr(backend, GitOdbBackend.GCHandleOffset)).Target as OdbBackend; @@ -360,7 +360,7 @@ private static unsafe int Write( IntPtr backend, IntPtr data, UIntPtr len, - Core.GitObjectType type) + GitObjectType type) { OdbBackend odbBackend = GCHandle.FromIntPtr(Marshal.ReadIntPtr(backend, GitOdbBackend.GCHandleOffset)).Target as OdbBackend; @@ -398,7 +398,7 @@ private static int WriteStream( out IntPtr stream_out, IntPtr backend, UIntPtr length, - Core.GitObjectType type) + GitObjectType type) { stream_out = IntPtr.Zero; diff --git a/LibGit2Sharp/Properties/AssemblyInfo.cs b/LibGit2Sharp/Properties/AssemblyInfo.cs index 159a40851..f3a5e7c25 100644 --- a/LibGit2Sharp/Properties/AssemblyInfo.cs +++ b/LibGit2Sharp/Properties/AssemblyInfo.cs @@ -42,5 +42,5 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.11.0")] -[assembly: AssemblyFileVersion("0.11.0")] +[assembly: AssemblyVersion("0.12.0")] +[assembly: AssemblyFileVersion("0.12.0")] diff --git a/LibGit2Sharp/ReferenceCollection.cs b/LibGit2Sharp/ReferenceCollection.cs index 7a03fd150..76db39e7a 100644 --- a/LibGit2Sharp/ReferenceCollection.cs +++ b/LibGit2Sharp/ReferenceCollection.cs @@ -50,7 +50,7 @@ public virtual Reference this[string name] /// An object that can be used to iterate through the collection. public virtual IEnumerator GetEnumerator() { - return Proxy.git_reference_list(repo.Handle, GitReferenceType.ListAll) + return Proxy.git_reference_list(repo.Handle) .Select(n => this[n]) .GetEnumerator(); } @@ -267,7 +267,7 @@ public virtual IEnumerable FromGlob(string pattern) { Ensure.ArgumentNotNullOrEmptyString(pattern, "pattern"); - return Proxy.git_reference_foreach_glob(repo.Handle, pattern, GitReferenceType.ListAll, Utf8Marshaler.FromNative) + return Proxy.git_reference_foreach_glob(repo.Handle, pattern, Utf8Marshaler.FromNative) .Select(n => this[n]); } diff --git a/LibGit2Sharp/ReferenceCollectionExtensions.cs b/LibGit2Sharp/ReferenceCollectionExtensions.cs index 3d7c0905f..15cbaa50d 100644 --- a/LibGit2Sharp/ReferenceCollectionExtensions.cs +++ b/LibGit2Sharp/ReferenceCollectionExtensions.cs @@ -47,7 +47,7 @@ public static Reference Add(this ReferenceCollection refsColl, string name, stri Reference reference; RefState refState = TryResolveReference(out reference, refsColl, canonicalRefNameOrObjectish); - var gitObject = refsColl.repo.Lookup(canonicalRefNameOrObjectish, Core.GitObjectType.Any, LookUpOptions.None); + var gitObject = refsColl.repo.Lookup(canonicalRefNameOrObjectish, GitObjectType.Any, LookUpOptions.None); if (refState == RefState.Exists) { diff --git a/LibGit2Sharp/Remote.cs b/LibGit2Sharp/Remote.cs index 64cd92f4b..8c402fe35 100644 --- a/LibGit2Sharp/Remote.cs +++ b/LibGit2Sharp/Remote.cs @@ -3,7 +3,6 @@ using System.Globalization; using LibGit2Sharp.Core; using LibGit2Sharp.Core.Handles; -using LibGit2Sharp.Handlers; namespace LibGit2Sharp { @@ -51,28 +50,6 @@ internal static Remote BuildFromPtr(RemoteSafeHandle handle, Repository repo) /// public virtual string Url { get; private set; } - /// - /// Fetch from the . - /// - /// Optional parameter indicating what tags to download. - /// Progress callback. Corresponds to libgit2 progress callback. - /// Completion callback. Corresponds to libgit2 completion callback. - /// UpdateTips callback. Corresponds to libgit2 update_tips callback. - /// Callback method that transfer progress will be reported through. - /// Reports the client's state regarding the received and processed (bytes, objects) from the server. - /// Credentials to use for username/password authentication. - [Obsolete("This method will be removed in the next release. Please use Repository.Network.Fetch() instead.")] - public virtual void Fetch( - TagFetchMode tagFetchMode = TagFetchMode.Auto, - ProgressHandler onProgress = null, - CompletionHandler onCompletion = null, - UpdateTipsHandler onUpdateTips = null, - TransferProgressHandler onTransferProgress = null, - Credentials credentials = null) - { - repository.Network.Fetch(this, tagFetchMode, onProgress, onCompletion, onUpdateTips, onTransferProgress, credentials); - } - /// /// Transform a reference to its source reference using the 's default fetchspec. /// diff --git a/LibGit2Sharp/Repository.cs b/LibGit2Sharp/Repository.cs index 819e606fe..57cabb2e8 100644 --- a/LibGit2Sharp/Repository.cs +++ b/LibGit2Sharp/Repository.cs @@ -392,7 +392,7 @@ public static Repository Init(string path, bool isBare = false, RepositoryOption /// The or null if it was not found. public GitObject Lookup(ObjectId id) { - return LookupInternal(id, Core.GitObjectType.Any, null); + return LookupInternal(id, GitObjectType.Any, null); } /// @@ -402,7 +402,7 @@ public GitObject Lookup(ObjectId id) /// The or null if it was not found. public GitObject Lookup(string objectish) { - return Lookup(objectish, Core.GitObjectType.Any, LookUpOptions.None); + return Lookup(objectish, GitObjectType.Any, LookUpOptions.None); } /// @@ -427,19 +427,7 @@ public GitObject Lookup(string objectish, ObjectType type) return Lookup(objectish, type.ToGitObjectType(), LookUpOptions.None); } - /// - /// Try to lookup an object by its and . If no matching object is found, null will be returned. - /// - /// The id to lookup. - /// The kind of GitObject being looked up - /// The or null if it was not found. - [Obsolete("This method will be removed in the next release. Please use another Repository.Lookup() overload instead.")] - public GitObject Lookup(ObjectId id, GitObjectType type = GitObjectType.Any) - { - return LookupInternal(id, type.ToCoreGitObjectType(), null); - } - - internal GitObject LookupInternal(ObjectId id, Core.GitObjectType type, FilePath knownPath) + internal GitObject LookupInternal(ObjectId id, GitObjectType type, FilePath knownPath) { Ensure.ArgumentNotNull(id, "id"); @@ -462,18 +450,6 @@ internal GitObject LookupInternal(ObjectId id, Core.GitObjectType type, FilePath } } - /// - /// Try to lookup an object by its sha or a reference canonical name and . If no matching object is found, null will be returned. - /// - /// A revparse spec for the object to lookup. - /// The kind of being looked up - /// The or null if it was not found. - [Obsolete("This method will be removed in the next release. Please use another Repository.Lookup() overload instead.")] - public GitObject Lookup(string objectish, GitObjectType type = GitObjectType.Any) - { - return Lookup(objectish, type.ToCoreGitObjectType(), LookUpOptions.None); - } - private static string PathFromRevparseSpec(string spec) { if (spec.StartsWith(":/", StringComparison.Ordinal)) @@ -490,7 +466,7 @@ private static string PathFromRevparseSpec(string spec) return (m.Groups.Count > 1) ? m.Groups[1].Value : null; } - internal GitObject Lookup(string objectish, Core.GitObjectType type, LookUpOptions lookUpOptions) + internal GitObject Lookup(string objectish, GitObjectType type, LookUpOptions lookUpOptions) { Ensure.ArgumentNotNullOrEmptyString(objectish, "commitOrBranchSpec"); @@ -507,9 +483,9 @@ internal GitObject Lookup(string objectish, Core.GitObjectType type, LookUpOptio return null; } - Core.GitObjectType objType = Proxy.git_object_type(sh); + GitObjectType objType = Proxy.git_object_type(sh); - if (type != Core.GitObjectType.Any && objType != type) + if (type != GitObjectType.Any && objType != type) { return null; } @@ -533,7 +509,7 @@ internal GitObject Lookup(string objectish, Core.GitObjectType type, LookUpOptio /// The commit. internal Commit LookupCommit(string committish) { - return (Commit)Lookup(committish, Core.GitObjectType.Any, LookUpOptions.ThrowWhenNoGitObjectHasBeenFound | LookUpOptions.DereferenceResultToCommit | LookUpOptions.ThrowWhenCanNotBeDereferencedToACommit); + return (Commit)Lookup(committish, GitObjectType.Any, LookUpOptions.ThrowWhenNoGitObjectHasBeenFound | LookUpOptions.DereferenceResultToCommit | LookUpOptions.ThrowWhenCanNotBeDereferencedToACommit); } /// @@ -751,6 +727,8 @@ public void Reset(ResetOptions resetOptions, Commit commit) Ensure.ArgumentNotNull(commit, "commit"); Proxy.git_reset(handle, commit.Id, resetOptions); + + Refs.Log(Refs.Head).Append(commit.Id, string.Format("reset: moving to {0}", commit.Sha)); } /// diff --git a/LibGit2Sharp/RepositoryInformation.cs b/LibGit2Sharp/RepositoryInformation.cs index 91934c0f9..2944e5191 100644 --- a/LibGit2Sharp/RepositoryInformation.cs +++ b/LibGit2Sharp/RepositoryInformation.cs @@ -26,6 +26,7 @@ internal RepositoryInformation(Repository repo, bool isBare) Path = path.Native; WorkingDirectory = workingDirectoryPath == null ? null : workingDirectoryPath.Native; + IsShallow = Proxy.git_repository_is_shallow(repo.Handle); } /// @@ -46,6 +47,11 @@ internal RepositoryInformation(Repository repo, bool isBare) /// public virtual bool IsBare { get; private set; } + /// + /// Indicates whether the repository is shallow (the result of `git clone --depth ...`) + /// + public virtual bool IsShallow { get; private set; } + /// /// Indicates whether the Head points to an arbitrary commit instead of the tip of a local branch. /// diff --git a/LibGit2Sharp/StashCollection.cs b/LibGit2Sharp/StashCollection.cs index 33cbf294e..0dc503403 100644 --- a/LibGit2Sharp/StashCollection.cs +++ b/LibGit2Sharp/StashCollection.cs @@ -69,7 +69,7 @@ public virtual Stash this[int index] throw new ArgumentOutOfRangeException("index", "The passed index must be a positive integer."); } - GitObject stashCommit = repo.Lookup(string.Format("stash@{{{0}}}", index), Core.GitObjectType.Commit, LookUpOptions.None); + GitObject stashCommit = repo.Lookup(string.Format("stash@{{{0}}}", index), GitObjectType.Commit, LookUpOptions.None); return stashCommit == null ? null : new Stash(repo, stashCommit.Id, index); } @@ -113,43 +113,6 @@ public virtual void Remove(int index) Proxy.git_stash_drop(repo.Handle, index); } - /// - /// Remove a single stashed state from the stash list. - /// - /// The log reference of the stash to delete. Pattern is "stash@{i}" where i is the index of the stash to remove - [Obsolete("This method will be removed in the next release. Please use Repository.Stashes.Remove(int) instead.")] - public virtual void Remove(string stashRefLog) - { - Ensure.ArgumentNotNullOrEmptyString(stashRefLog, "stashRefLog"); - - int index; - if (!TryExtractStashIndexFromRefLog(stashRefLog, out index) || index < 0) - { - throw new ArgumentException("must be a valid stash log reference. Pattern is 'stash@{i}' where 'i' is an integer", "stashRefLog"); - } - - Remove(index); - } - - private static bool TryExtractStashIndexFromRefLog(string stashRefLog, out int index) - { - index = -1; - - if (!stashRefLog.StartsWith("stash@{")) - { - return false; - } - - if (!stashRefLog.EndsWith("}")) - { - return false; - } - - var indexAsString = stashRefLog.Substring(7, stashRefLog.Length - 8); - - return int.TryParse(indexAsString, out index); - } - private string DebuggerDisplay { get diff --git a/LibGit2Sharp/TagCollectionExtensions.cs b/LibGit2Sharp/TagCollectionExtensions.cs index 210ba9713..413f37e1f 100644 --- a/LibGit2Sharp/TagCollectionExtensions.cs +++ b/LibGit2Sharp/TagCollectionExtensions.cs @@ -20,7 +20,7 @@ public static Tag Add(this TagCollection tags, string name, string objectish, Si { Ensure.ArgumentNotNullOrEmptyString(objectish, "target"); - GitObject objectToTag = tags.repo.Lookup(objectish, Core.GitObjectType.Any, LookUpOptions.ThrowWhenNoGitObjectHasBeenFound); + GitObject objectToTag = tags.repo.Lookup(objectish, GitObjectType.Any, LookUpOptions.ThrowWhenNoGitObjectHasBeenFound); return tags.Add(name, objectToTag, tagger, message, allowOverwrite); } @@ -36,7 +36,7 @@ public static Tag Add(this TagCollection tags, string name, string objectish, bo { Ensure.ArgumentNotNullOrEmptyString(objectish, "objectish"); - GitObject objectToTag = tags.repo.Lookup(objectish, Core.GitObjectType.Any, LookUpOptions.ThrowWhenNoGitObjectHasBeenFound); + GitObject objectToTag = tags.repo.Lookup(objectish, GitObjectType.Any, LookUpOptions.ThrowWhenNoGitObjectHasBeenFound); return tags.Add(name, objectToTag, allowOverwrite); } diff --git a/LibGit2Sharp/TagFetchMode.cs b/LibGit2Sharp/TagFetchMode.cs index 13024cb0c..6e06eb37e 100644 --- a/LibGit2Sharp/TagFetchMode.cs +++ b/LibGit2Sharp/TagFetchMode.cs @@ -6,16 +6,16 @@ /// public enum TagFetchMode { - /// - /// No tag will be retrieved. - /// - None = 1, // GIT_REMOTE_DOWNLOAD_TAGS_NONE - /// /// Default behavior. Will automatically retrieve tags that /// point to objects retrieved during this fetch. /// - Auto, // GIT_REMOTE_DOWNLOAD_TAGS_AUTO + Auto = 0, // GIT_REMOTE_DOWNLOAD_TAGS_AUTO + + /// + /// No tag will be retrieved. + /// + None, // GIT_REMOTE_DOWNLOAD_TAGS_NONE /// /// All tags will be downloaded, but _only_ tags, along with diff --git a/LibGit2Sharp/TreeEntry.cs b/LibGit2Sharp/TreeEntry.cs index bcf92d6bc..28baaa80c 100644 --- a/LibGit2Sharp/TreeEntry.cs +++ b/LibGit2Sharp/TreeEntry.cs @@ -32,8 +32,7 @@ internal TreeEntry(SafeHandle obj, ObjectId parentTreeId, Repository repo, FileP this.repo = repo; targetOid = Proxy.git_tree_entry_id(obj); - Core.GitObjectType treeEntryTargetType = Proxy.git_tree_entry_type(obj); - Type = treeEntryTargetType.ToGitObjectType(); + GitObjectType treeEntryTargetType = Proxy.git_tree_entry_type(obj); TargetType = treeEntryTargetType.ToTreeEntryTargetType(); target = new Lazy(RetrieveTreeEntryTarget); @@ -69,12 +68,6 @@ internal ObjectId TargetId get { return targetOid; } } - /// - /// Gets the of the being pointed at. - /// - [Obsolete("This property will be removed in the next release. Please use TreeEntry.TargetType instead.")] - public virtual GitObjectType Type { get; private set; } - /// /// Gets the of the being pointed at. /// diff --git a/LibGit2Sharp/TreeEntryDefinition.cs b/LibGit2Sharp/TreeEntryDefinition.cs index 5ef55b2dd..13e2fd2ea 100644 --- a/LibGit2Sharp/TreeEntryDefinition.cs +++ b/LibGit2Sharp/TreeEntryDefinition.cs @@ -14,7 +14,7 @@ public class TreeEntryDefinition : IEquatable private static readonly LambdaEqualityHelper equalityHelper = new LambdaEqualityHelper(x => x.Mode, x => x.TargetType, x => x.TargetId); - internal static readonly Mode[] BlobModes = new[] { Mode.NonExecutableFile, Mode.ExecutableFile, Mode.NonExecutableGroupWritableFile, Mode.SymbolicLink }; + internal static readonly Enum[] BlobModes = new Enum[] { Mode.NonExecutableFile, Mode.ExecutableFile, Mode.NonExecutableGroupWritableFile, Mode.SymbolicLink }; /// /// Needed for mocking purposes. @@ -28,12 +28,6 @@ protected TreeEntryDefinition() /// public virtual Mode Mode { get; private set; } - /// - /// Gets the of the target being pointed at. - /// - [Obsolete("This property will be removed in the next release. Please use TreeEntryDefinition.TargetType instead.")] - public virtual GitObjectType Type { get; private set; } - /// /// Gets the of the target being pointed at. /// @@ -54,7 +48,6 @@ internal static TreeEntryDefinition From(TreeEntry treeEntry) return new TreeEntryDefinition { Mode = treeEntry.Mode, - Type = treeEntry.Type, TargetType = treeEntry.TargetType, TargetId = treeEntry.TargetId, target = new Lazy(() => treeEntry.Target) @@ -66,7 +59,6 @@ internal static TreeEntryDefinition From(Blob blob, Mode mode) return new TreeEntryDefinition { Mode = mode, - Type = GitObjectType.Blob, TargetType = TreeEntryTargetType.Blob, TargetId = blob.Id, target = new Lazy(() => blob) @@ -89,7 +81,6 @@ internal static TreeEntryDefinition From(ObjectId objectId) return new TreeEntryDefinition { Mode = Mode.GitLink, - Type = GitObjectType.Commit, TargetType = TreeEntryTargetType.GitLink, TargetId = objectId, target = new Lazy(() => { throw new InvalidOperationException("Shouldn't be necessary."); }), @@ -101,7 +92,6 @@ internal static TreeEntryDefinition From(Tree tree) return new TreeEntryDefinition { Mode = Mode.Directory, - Type = GitObjectType.Tree, TargetType = TreeEntryTargetType.Tree, TargetId = tree.Id, target = new Lazy(() => tree) @@ -180,12 +170,6 @@ public override Mode Mode get { return Mode.Directory; } } - [Obsolete("This property will be removed in the next release. Please use TransientTreeTreeEntryDefinition.TargetType instead.")] - public override GitObjectType Type - { - get { return GitObjectType.Tree; } - } - public override TreeEntryTargetType TargetType { get { return TreeEntryTargetType.Tree; } @@ -194,12 +178,6 @@ public override TreeEntryTargetType TargetType internal class TransientBlobTreeEntryDefinition : TransientTreeEntryDefinition { - [Obsolete("This property will be removed in the next release. Please use TransientBlobTreeEntryDefinition.TargetType instead.")] - public override GitObjectType Type - { - get { return GitObjectType.Blob; } - } - public override TreeEntryTargetType TargetType { get { return TreeEntryTargetType.Blob; } diff --git a/LibGit2Sharp/TreeEntryTargetType.cs b/LibGit2Sharp/TreeEntryTargetType.cs index 0178b92d5..b6a5a2d84 100644 --- a/LibGit2Sharp/TreeEntryTargetType.cs +++ b/LibGit2Sharp/TreeEntryTargetType.cs @@ -1,4 +1,5 @@ using System; +using LibGit2Sharp.Core; namespace LibGit2Sharp { @@ -20,6 +21,7 @@ public enum TreeEntryTargetType /// /// An annotated tag object. /// + [Obsolete("This entry will be removed in the next release as it is not a valid TreeEntryTargetType.")] Tag, /// @@ -30,15 +32,15 @@ public enum TreeEntryTargetType internal static class TreeEntryTargetTypeExtensions { - public static Core.GitObjectType ToGitObjectType(this TreeEntryTargetType type) + public static GitObjectType ToGitObjectType(this TreeEntryTargetType type) { switch (type) { case TreeEntryTargetType.Tree: - return Core.GitObjectType.Tree; + return GitObjectType.Tree; case TreeEntryTargetType.Blob: - return Core.GitObjectType.Blob; + return GitObjectType.Blob; default: throw new InvalidOperationException(string.Format("Cannot map {0} to a GitObjectType.", type)); diff --git a/LibGit2Sharp/UniqueIdentifier.targets b/LibGit2Sharp/UniqueIdentifier.targets new file mode 100644 index 000000000..8b97c65d3 --- /dev/null +++ b/LibGit2Sharp/UniqueIdentifier.targets @@ -0,0 +1,25 @@ + + + + + + + + + Core\UniqueIdentifier.cs + $(CoreCompileDependsOn);GenerateUniqueIdentifierCs + $(CoreCleanDependsOn);CleanUniqueIdentifierCs + + + + + + + + + + + diff --git a/LibGit2Sharp/libgit2_hash.txt b/LibGit2Sharp/libgit2_hash.txt index 5d90d86df..e7f26f1d5 100644 --- a/LibGit2Sharp/libgit2_hash.txt +++ b/LibGit2Sharp/libgit2_hash.txt @@ -1 +1 @@ -b641c00eebb3c60e8719c0dfc55dde91ca30a5d2 +9d9fff3c3dbc207a8a2ee2114eab19086afecb6e diff --git a/LibGit2Sharp/libgit2sharp_hash.txt b/LibGit2Sharp/libgit2sharp_hash.txt index 0faec6021..354664565 100644 --- a/LibGit2Sharp/libgit2sharp_hash.txt +++ b/LibGit2Sharp/libgit2sharp_hash.txt @@ -1 +1 @@ -unknown +unknown diff --git a/UpdateLibgit2ToSha.ps1 b/UpdateLibgit2ToSha.ps1 index c768b14d6..bf35ca98c 100644 --- a/UpdateLibgit2ToSha.ps1 +++ b/UpdateLibgit2ToSha.ps1 @@ -111,6 +111,7 @@ Push-Location $libgit2Directory popd break } + $shortsha = $sha.Substring(0,7) Write-Output "Checking out $sha..." Run-Command -Quiet -Fatal { & $git checkout $sha } @@ -119,26 +120,41 @@ Push-Location $libgit2Directory Run-Command -Quiet { & remove-item build -recurse -force } Run-Command -Quiet { & mkdir build } cd build - Run-Command -Quiet -Fatal { & $cmake -G "Visual Studio $vs" -D THREADSAFE=ON -D "BUILD_CLAR=$build_clar" .. } + Run-Command -Quiet -Fatal { & $cmake -G "Visual Studio $vs" -D THREADSAFE=ON -D "BUILD_CLAR=$build_clar" -D "SONAME_APPEND=$shortsha" .. } Run-Command -Quiet -Fatal { & $cmake --build . --config $configuration } if ($test.IsPresent) { Run-Command -Quiet -Fatal { & $ctest -V . } } cd $configuration Run-Command -Quiet { & rm *.exp } + Run-Command -Quiet { & rm $x86Directory\* } Run-Command -Quiet -Fatal { & copy -fo * $x86Directory } Write-Output "Building 64-bit..." cd .. Run-Command -Quiet { & mkdir build64 } cd build64 - Run-Command -Quiet -Fatal { & $cmake -G "Visual Studio $vs Win64" -D THREADSAFE=ON -D "BUILD_CLAR=$build_clar" ../.. } + Run-Command -Quiet -Fatal { & $cmake -G "Visual Studio $vs Win64" -D THREADSAFE=ON -D "BUILD_CLAR=$build_clar" -D "SONAME_APPEND=$shortsha" ../.. } Run-Command -Quiet -Fatal { & $cmake --build . --config $configuration } if ($test.IsPresent) { Run-Command -Quiet -Fatal { & $ctest -V . } } cd $configuration Run-Command -Quiet { & rm *.exp } + Run-Command -Quiet { & rm $x64Directory\* } Run-Command -Quiet -Fatal { & copy -fo * $x64Directory } - Write-Output "Done!" pop-location - sc -Encoding UTF8 libgit2sharp\libgit2_hash.txt $sha + + $dllNameClass = @" +namespace LibGit2Sharp.Core +{ + internal static class NativeDllName + { + public const string Name = "git2-$shortsha"; + } +} +"@ + + sc -Encoding ASCII .\Libgit2sharp\Core\NativeDllName.cs $dllNameClass + sc -Encoding ASCII libgit2sharp\libgit2_hash.txt $sha + + Write-Output "Done!" } exit diff --git a/build.libgit2sharp.sh b/build.libgit2sharp.sh index c5f1948f9..c1b151ed8 100644 --- a/build.libgit2sharp.sh +++ b/build.libgit2sharp.sh @@ -1,11 +1,14 @@ -#!/bin/sh +#!/bin/bash PREVIOUS_LD=$LD_LIBRARY_PATH +LIBGIT2SHA=`cat ./LibGit2Sharp/libgit2_hash.txt` +SHORTSHA=${LIBGIT2SHA:0:7} + rm -rf cmake-build mkdir cmake-build && cd cmake-build -cmake -DBUILD_SHARED_LIBS:BOOL=ON -DTHREADSAFE:BOOL=ON -DBUILD_CLAR:BOOL=OFF -DCMAKE_INSTALL_PREFIX=./libgit2-bin ../libgit2 +cmake -DBUILD_SHARED_LIBS:BOOL=ON -DTHREADSAFE:BOOL=ON -DBUILD_CLAR:BOOL=OFF -DCMAKE_INSTALL_PREFIX=./libgit2-bin -DSONAME_APPEND=$SHORTSHA ../libgit2 cmake --build . --target install LD_LIBRARY_PATH=$PWD/libgit2-bin/lib:$LD_LIBRARY_PATH diff --git a/libgit2 b/libgit2 index b641c00ee..9d9fff3c3 160000 --- a/libgit2 +++ b/libgit2 @@ -1 +1 @@ -Subproject commit b641c00eebb3c60e8719c0dfc55dde91ca30a5d2 +Subproject commit 9d9fff3c3dbc207a8a2ee2114eab19086afecb6e diff --git a/nuget.package/build.nuget.package.cmd b/nuget.package/build.nuget.package.cmd index e36c3f156..6def1d6d7 100644 --- a/nuget.package/build.nuget.package.cmd +++ b/nuget.package/build.nuget.package.cmd @@ -3,6 +3,11 @@ SET BASEDIR=%~dp0 SET SRCDIR=%BASEDIR%..\LibGit2Sharp\ SET CommitSha=%~1 +IF "%CommitSha%" == "" ( + ECHO "Please provide the Libgit2Sharp commit Sha this package is being built from." + EXIT /B 1 +) + REM the nuspec file needs to be next to the csproj, so copy it there during the pack operation COPY "%BASEDIR%LibGit2Sharp.nuspec" "%SRCDIR%"