diff --git a/CHANGES.md b/CHANGES.md index b26dac602..9dee434dc 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -10,6 +10,37 @@ - CodeBetter TeamCity: - Travis: +## v0.19 - ([diff](https://github.com/libgit2/libgit2sharp/compare/v0.18.1...v0.19)) + +### Additions + + - Introduce repo.Network.Remotes.Rename() (#730, #741) + - Introduce repo.ObjectDatabase.ShortenObjectId() (#677) + - Introduce Remote.IsSupportedUrl() (#754) + - Introduce repo.CherryPick() (#755, #756) + - Expose advanced conflict data (REUC, renames) (#748) + +### Changes + + - Make Patch expose a richer PatchEntryChanges type (#686, #702) + - Make network operations accept Credentials through a callback (#759, #761, #767) + - Make repo.Index.Stage() respect ignored files by default (#777) + - Make OdbBackend IDisposable (#713) + - Update libgit2 binaries to libgit2/libgit2@d28b2b7 + +### Fixes + + - Don't require specific rights to the parent hierarchy of a repository (#795) + - Prevent Clone() from choking on empty packets (#794) + - Ensure Tags can be created in detached Head state (#791) + - Properly determine object size when calculating its CRC (#783) + - Prevent blind fast forwards merges when there are checkout conflicts (#781) + - Make repo.Reset() and repo.Index.Unstage() cope with renamed entries (#777) + - Do not throw when parsing annotated tags without a Signature (#775, #776) + - Remove conflicts upon repo.Index.Remove() call (#768) + - Honor the merge.ff configuration entry (#709) + - Make Clone() properly throws when passed an invalid url (#701) + ## v0.18.1 - ([diff](https://github.com/libgit2/libgit2sharp/compare/v0.18.0...v0.18.1)) ### Additions diff --git a/Lib/NativeBinaries/amd64/git2-091165c.dll b/Lib/NativeBinaries/amd64/git2-091165c.dll deleted file mode 100644 index 0c5dff5bc..000000000 Binary files a/Lib/NativeBinaries/amd64/git2-091165c.dll and /dev/null differ diff --git a/Lib/NativeBinaries/amd64/git2-091165c.pdb b/Lib/NativeBinaries/amd64/git2-091165c.pdb deleted file mode 100644 index d8e3ae44c..000000000 Binary files a/Lib/NativeBinaries/amd64/git2-091165c.pdb and /dev/null differ diff --git a/Lib/NativeBinaries/amd64/git2-69db893.dll b/Lib/NativeBinaries/amd64/git2-69db893.dll new file mode 100644 index 000000000..1b4395446 Binary files /dev/null and b/Lib/NativeBinaries/amd64/git2-69db893.dll differ diff --git a/Lib/NativeBinaries/amd64/git2-69db893.pdb b/Lib/NativeBinaries/amd64/git2-69db893.pdb new file mode 100644 index 000000000..7ac433959 Binary files /dev/null and b/Lib/NativeBinaries/amd64/git2-69db893.pdb differ diff --git a/Lib/NativeBinaries/x86/git2-091165c.dll b/Lib/NativeBinaries/x86/git2-091165c.dll deleted file mode 100644 index 3e941b240..000000000 Binary files a/Lib/NativeBinaries/x86/git2-091165c.dll and /dev/null differ diff --git a/Lib/NativeBinaries/x86/git2-091165c.pdb b/Lib/NativeBinaries/x86/git2-091165c.pdb deleted file mode 100644 index c4a5864a0..000000000 Binary files a/Lib/NativeBinaries/x86/git2-091165c.pdb and /dev/null differ diff --git a/Lib/NativeBinaries/x86/git2-69db893.dll b/Lib/NativeBinaries/x86/git2-69db893.dll new file mode 100644 index 000000000..4295b98eb Binary files /dev/null and b/Lib/NativeBinaries/x86/git2-69db893.dll differ diff --git a/Lib/NativeBinaries/x86/git2-69db893.pdb b/Lib/NativeBinaries/x86/git2-69db893.pdb new file mode 100644 index 000000000..1a4fcf5c7 Binary files /dev/null and b/Lib/NativeBinaries/x86/git2-69db893.pdb differ diff --git a/LibGit2Sharp.Tests/CloneFixture.cs b/LibGit2Sharp.Tests/CloneFixture.cs index 88629b1f4..a3b35d8b3 100644 --- a/LibGit2Sharp.Tests/CloneFixture.cs +++ b/LibGit2Sharp.Tests/CloneFixture.cs @@ -191,5 +191,13 @@ public void CanCloneFromBBWithCredentials(string url, string user, string pass) Assert.False(repo.Info.IsBare); } } + + [Fact] + public void CloningAnUrlWithoutPathThrows() + { + var scd = BuildSelfCleaningDirectory(); + + Assert.Throws(() => Repository.Clone("http://github.com", scd.DirectoryPath)); + } } } diff --git a/LibGit2Sharp.Tests/ConfigurationFixture.cs b/LibGit2Sharp.Tests/ConfigurationFixture.cs index 0e7774617..ad085a5a0 100644 --- a/LibGit2Sharp.Tests/ConfigurationFixture.cs +++ b/LibGit2Sharp.Tests/ConfigurationFixture.cs @@ -80,30 +80,6 @@ public void CanUnsetAnEntryFromTheGlobalConfiguration() } } - [SkippableFact] - public void CanGetGlobalStringValue() - { - using (var repo = new Repository(StandardTestRepoPath)) - { - InconclusiveIf(() => !repo.Config.HasConfig(ConfigurationLevel.Global), - "No Git global configuration available"); - - Assert.NotNull(repo.Config.Get("user.name")); - } - } - - [SkippableFact] - public void CanGetGlobalStringValueWithoutRepo() - { - using (var config = new Configuration()) - { - InconclusiveIf(() => !config.HasConfig(ConfigurationLevel.Global), - "No Git global configuration available"); - - Assert.NotNull(config.Get("user.name")); - } - } - [Fact] public void CanReadBooleanValue() { @@ -264,54 +240,6 @@ public void CanSetBooleanValue() } } - [SkippableFact] - public void CanSetGlobalStringValue() - { - using (var repo = new Repository(StandardTestRepoPath)) - { - InconclusiveIf(() => !repo.Config.HasConfig(ConfigurationLevel.Global), - "No Git global configuration available"); - - var existing = repo.Config.Get("user.name"); - Assert.NotNull(existing); - - try - { - repo.Config.Set("user.name", "Unit Test", ConfigurationLevel.Global); - - AssertValueInGlobalConfigFile("name = Unit Test$"); - } - finally - { - repo.Config.Set("user.name", existing.Value, ConfigurationLevel.Global); - } - } - } - - [SkippableFact] - public void CanSetGlobalStringValueWithoutRepo() - { - using(var config = new Configuration()) - { - InconclusiveIf(() => !config.HasConfig(ConfigurationLevel.Global), - "No Git global configuration available"); - - var existing = config.Get("user.name"); - Assert.NotNull(existing); - - try - { - config.Set("user.name", "Unit Test", ConfigurationLevel.Global); - - AssertValueInGlobalConfigFile("name = Unit Test$"); - } - finally - { - config.Set("user.name", existing.Value, ConfigurationLevel.Global); - } - } - } - [Fact] public void SettingLocalConfigurationOutsideAReposThrows() { diff --git a/LibGit2Sharp.Tests/MergeFixture.cs b/LibGit2Sharp.Tests/MergeFixture.cs index 8c480d8af..7801de718 100644 --- a/LibGit2Sharp.Tests/MergeFixture.cs +++ b/LibGit2Sharp.Tests/MergeFixture.cs @@ -351,7 +351,7 @@ public void MergeReportsCheckoutProgress() using (var repo = new Repository(repoPath)) { Commit commitToMerge = repo.Branches["normal_merge"].Tip; - + bool wasCalled = false; MergeOptions options = new MergeOptions() diff --git a/LibGit2Sharp.Tests/ObjectDatabaseFixture.cs b/LibGit2Sharp.Tests/ObjectDatabaseFixture.cs index 091876d8a..c6e724c10 100644 --- a/LibGit2Sharp.Tests/ObjectDatabaseFixture.cs +++ b/LibGit2Sharp.Tests/ObjectDatabaseFixture.cs @@ -563,7 +563,7 @@ public void CanShortenObjectIdentifier() /* * $ echo "aabqhq" | git hash-object -t blob --stdin * dea509d0b3cb8ee0650f6ca210bc83f4678851ba - * + * * $ echo "aaazvc" | git hash-object -t blob --stdin * dea509d097ce692e167dfc6a48a7a280cc5e877e */ diff --git a/LibGit2Sharp.Tests/OdbBackendFixture.cs b/LibGit2Sharp.Tests/OdbBackendFixture.cs index 9df69b089..c99442c9b 100644 --- a/LibGit2Sharp.Tests/OdbBackendFixture.cs +++ b/LibGit2Sharp.Tests/OdbBackendFixture.cs @@ -183,7 +183,7 @@ public void CanShortenObjectIdentifier() /* * $ echo "aabqhq" | git hash-object -t blob --stdin * dea509d0b3cb8ee0650f6ca210bc83f4678851ba - * + * * $ echo "aaazvc" | git hash-object -t blob --stdin * dea509d097ce692e167dfc6a48a7a280cc5e877e */ @@ -386,7 +386,7 @@ public override bool Exists(ObjectId oid) public override int ExistsPrefix(string shortSha, out ObjectId found) { - found = null; + found = null; int numFound = 0; foreach (ObjectId id in m_objectIdToContent.Keys) diff --git a/LibGit2Sharp.Tests/RepositoryFixture.cs b/LibGit2Sharp.Tests/RepositoryFixture.cs index f5916f5f2..7f4d208a0 100644 --- a/LibGit2Sharp.Tests/RepositoryFixture.cs +++ b/LibGit2Sharp.Tests/RepositoryFixture.cs @@ -110,7 +110,7 @@ public void CanRetrieveValidVersionString() Assert.True(regexResult.Success, "The following version string format is enforced:" + "Major.Minor.Patch-LibGit2Sharp_abbrev_hash-libgit2_abbrev_hash (x86|amd64 - features)"); - + GroupCollection matchGroups = regexResult.Groups; // Check that all groups are valid diff --git a/LibGit2Sharp.Tests/ResetHeadFixture.cs b/LibGit2Sharp.Tests/ResetHeadFixture.cs index 82fe2c535..870e46c39 100644 --- a/LibGit2Sharp.Tests/ResetHeadFixture.cs +++ b/LibGit2Sharp.Tests/ResetHeadFixture.cs @@ -18,7 +18,7 @@ public void ResetANewlyInitializedRepositoryThrows(bool isBare) using (var repo = new Repository(repoPath)) { - Assert.Throws(() => repo.Reset(ResetMode.Soft)); + Assert.Throws(() => repo.Reset(ResetMode.Soft)); } } diff --git a/LibGit2Sharp.Tests/ResetIndexFixture.cs b/LibGit2Sharp.Tests/ResetIndexFixture.cs index 0e774cd7e..9cc7849ac 100644 --- a/LibGit2Sharp.Tests/ResetIndexFixture.cs +++ b/LibGit2Sharp.Tests/ResetIndexFixture.cs @@ -25,7 +25,7 @@ public void ResetANewlyInitializedNonBareRepositoryThrows() using (var repo = new Repository(repoPath)) { - Assert.Throws(() => repo.Reset()); + Assert.Throws(() => repo.Reset()); } } diff --git a/LibGit2Sharp.Tests/StatusFixture.cs b/LibGit2Sharp.Tests/StatusFixture.cs index 4a63bc93d..b70ff0ae0 100644 --- a/LibGit2Sharp.Tests/StatusFixture.cs +++ b/LibGit2Sharp.Tests/StatusFixture.cs @@ -495,12 +495,8 @@ public void RetrievingTheStatusOfTheRepositoryHonorsTheGitIgnoreDirectivesThroug Assert.Equal(FileStatus.Ignored, repo.Index.RetrieveStatus("bin/look-ma.txt")); Assert.Equal(FileStatus.Untracked, repo.Index.RetrieveStatus("bin/what-about-me.txt")); - // bin/* is considered as ignoring the dir itself newStatus = repo.Index.RetrieveStatus(); - Assert.Equal(new[] { "bin" + dirSep }, newStatus.Ignored.Select(s => s.FilePath)); - // if we recurse into ignored dirs, then we get the actual list - newStatus = repo.Index.RetrieveStatus(new StatusOptions { RecurseIgnoredDirs = true }); Assert.Equal(new[] { "bin" + dirSep + "look-ma.txt" }, newStatus.Ignored.Select(s => s.FilePath)); Assert.True(newStatus.Untracked.Select(s => s.FilePath).Contains("bin" + dirSep + "what-about-me.txt")); } diff --git a/LibGit2Sharp.Tests/TagFixture.cs b/LibGit2Sharp.Tests/TagFixture.cs index 97f5b24d5..bd008af34 100644 --- a/LibGit2Sharp.Tests/TagFixture.cs +++ b/LibGit2Sharp.Tests/TagFixture.cs @@ -234,7 +234,7 @@ public void CreatingATagInAEmptyRepositoryThrows() using (var repo = new Repository(repoPath)) { - Assert.Throws(() => repo.ApplyTag("mynotag")); + Assert.Throws(() => repo.ApplyTag("mynotag")); } } @@ -246,7 +246,8 @@ public void CreatingATagForHeadInAEmptyRepositoryThrows() using (var repo = new Repository(repoPath)) { - Assert.Throws(() => repo.ApplyTag("mytaghead", "HEAD")); + Assert.Throws(() => repo.ApplyTag("mytaghead", "HEAD")); + Assert.Throws(() => repo.ApplyTag("mytaghead")); } } @@ -287,6 +288,26 @@ public void CanAddATagForImplicitHead() } } + [Fact] + public void CanAddATagForImplicitHeadInDetachedState() + { + string path = CloneStandardTestRepo(); + using (var repo = new Repository(path)) + { + repo.Checkout(repo.Head.Tip); + + Assert.True(repo.Info.IsHeadDetached); + + Tag tag = repo.ApplyTag("mytag"); + Assert.NotNull(tag); + + Assert.Equal(repo.Head.Tip.Id, tag.Target.Id); + + Tag retrievedTag = repo.Tags[tag.CanonicalName]; + Assert.Equal(retrievedTag, tag); + } + } + [Fact] // Ported from cgit (https://github.com/git/git/blob/1c08bf50cfcf924094eca56c2486a90e2bf1e6e2/t/t7004-tag.sh#L87) public void CreatingADuplicateTagThrows() @@ -364,7 +385,7 @@ public void CanReadTagWithoutTagger() Tree tree = repo.Lookup("581f9824ecaf824221bd36edf5430f2739a7c4f5"); Assert.NotNull(tree); - + Assert.Equal(tree.Id, tag.Target.Id); } } diff --git a/LibGit2Sharp/ChangeKind.cs b/LibGit2Sharp/ChangeKind.cs index 612e036d8..c95095a37 100644 --- a/LibGit2Sharp/ChangeKind.cs +++ b/LibGit2Sharp/ChangeKind.cs @@ -50,5 +50,10 @@ public enum ChangeKind /// of the file was changed. /// TypeChanged = 8, + + /// + /// Entry is unreadable. + /// + Unreadable = 9, } } diff --git a/LibGit2Sharp/CherryPickOptions.cs b/LibGit2Sharp/CherryPickOptions.cs index 0f27de211..05619f37b 100644 --- a/LibGit2Sharp/CherryPickOptions.cs +++ b/LibGit2Sharp/CherryPickOptions.cs @@ -49,7 +49,7 @@ public CherryPickOptions() /// /// When cherry picking a merge commit, the parent number to consider as - /// mainline, starting from offset 1. + /// mainline, starting from offset 1. /// /// As a merge commit has multiple parents, cherry picking a merge commit /// will reverse all the changes brought in by the merge except for diff --git a/LibGit2Sharp/Core/Ensure.cs b/LibGit2Sharp/Core/Ensure.cs index df11d3f60..5e7ea30b3 100644 --- a/LibGit2Sharp/Core/Ensure.cs +++ b/LibGit2Sharp/Core/Ensure.cs @@ -209,13 +209,32 @@ public static void ArgumentConformsTo(T argumentValue, Func checker, } public static void GitObjectIsNotNull(GitObject gitObject, string identifier) + { + Func exceptionBuilder; + + if (string.Equals("HEAD", identifier, StringComparison.Ordinal)) + { + exceptionBuilder = m => new UnbornBranchException(m); + } + else + { + exceptionBuilder = m => new LibGit2SharpException(m); + } + + GitObjectIsNotNull(gitObject, identifier, exceptionBuilder); + } + + public static void GitObjectIsNotNull( + GitObject gitObject, + string identifier, + Func exceptionBuilder) { if (gitObject != null) { return; } - throw new LibGit2SharpException(string.Format(CultureInfo.InvariantCulture, + throw exceptionBuilder(string.Format(CultureInfo.InvariantCulture, "No valid git object identified by '{0}' exists in the repository.", identifier)); } diff --git a/LibGit2Sharp/Core/GitDiff.cs b/LibGit2Sharp/Core/GitDiff.cs index 7581bcfbc..27b5fab19 100644 --- a/LibGit2Sharp/Core/GitDiff.cs +++ b/LibGit2Sharp/Core/GitDiff.cs @@ -112,6 +112,16 @@ internal enum GitDiffOptionFlags /// GIT_DIFF_UPDATE_INDEX = (1 << 15), + /// + /// Include unreadable files in the diff + /// + GIT_DIFF_INCLUDE_UNREADABLE = (1 << 16), + + /// + /// Include unreadable files in the diff + /// + GIT_DIFF_INCLUDE_UNREADABLE_AS_UNTRACKED = (1 << 17), + /* * Options controlling how output will be generated */ diff --git a/LibGit2Sharp/Core/GitStatusOptions.cs b/LibGit2Sharp/Core/GitStatusOptions.cs index af753a437..bc0956e8f 100644 --- a/LibGit2Sharp/Core/GitStatusOptions.cs +++ b/LibGit2Sharp/Core/GitStatusOptions.cs @@ -46,5 +46,7 @@ internal enum GitStatusOptionFlags RenamesFromRewrites = (1 << 11), NoRefresh = (1 << 12), UpdateIndex = (1 << 13), + IncludeUnreadable = (1 << 14), + IncludeUnreadableAsUntracked = (1 << 15), } } diff --git a/LibGit2Sharp/Core/NativeDllName.cs b/LibGit2Sharp/Core/NativeDllName.cs index b1ee94734..62603ace9 100644 --- a/LibGit2Sharp/Core/NativeDllName.cs +++ b/LibGit2Sharp/Core/NativeDllName.cs @@ -2,6 +2,6 @@ namespace LibGit2Sharp.Core { internal static class NativeDllName { - public const string Name = "git2-091165c"; + public const string Name = "git2-69db893"; } } diff --git a/LibGit2Sharp/Core/NativeMethods.cs b/LibGit2Sharp/Core/NativeMethods.cs index f6bb9c759..9a3d72076 100644 --- a/LibGit2Sharp/Core/NativeMethods.cs +++ b/LibGit2Sharp/Core/NativeMethods.cs @@ -1532,7 +1532,7 @@ internal static extern int git_treebuilder_insert( internal static extern int git_blob_is_binary(GitObjectSafeHandle blob); [DllImport(libgit2)] - internal static extern int git_cherry_pick(RepositorySafeHandle repo, GitObjectSafeHandle commit, GitCherryPickOptions options); + internal static extern int git_cherrypick(RepositorySafeHandle repo, GitObjectSafeHandle commit, GitCherryPickOptions options); } } // ReSharper restore InconsistentNaming diff --git a/LibGit2Sharp/Core/Proxy.cs b/LibGit2Sharp/Core/Proxy.cs index 4850a0b5d..5ab210936 100644 --- a/LibGit2Sharp/Core/Proxy.cs +++ b/LibGit2Sharp/Core/Proxy.cs @@ -73,7 +73,7 @@ public static ObjectId git_blob_create_fromchunks(RepositorySafeHandle repo, Fil if (res == (int)GitErrorCode.User) { - throw new EndOfStreamException("The stream ended unexpectedly"); + throw new EndOfStreamException("The stream ended unexpectedly"); } Ensure.ZeroResult(res); @@ -270,12 +270,12 @@ public static void git_checkout_index(RepositorySafeHandle repo, GitObjectSafeHa #region git_cherry_pick_ - internal static void git_cherry_pick(RepositorySafeHandle repo, ObjectId commit, GitCherryPickOptions options) + internal static void git_cherrypick(RepositorySafeHandle repo, ObjectId commit, GitCherryPickOptions options) { using (ThreadAffinity()) using (var nativeCommit = git_object_lookup(repo, commit, GitObjectType.Commit)) { - int res = NativeMethods.git_cherry_pick(repo, nativeCommit, options); + int res = NativeMethods.git_cherrypick(repo, nativeCommit, options); Ensure.ZeroResult(res); } } diff --git a/LibGit2Sharp/FileStatus.cs b/LibGit2Sharp/FileStatus.cs index 08fa73f60..68e41b7b5 100644 --- a/LibGit2Sharp/FileStatus.cs +++ b/LibGit2Sharp/FileStatus.cs @@ -68,6 +68,11 @@ public enum FileStatus /// RenamedInWorkDir = (1 << 11), /* GIT_STATUS_WT_RENAMED */ + /// + /// The file is unreadable in the working directory. + /// + Unreadable = (1 << 12), /* GIT_STATUS_WT_UNREADABLE */ + /// /// The file is but its name and/or path matches an exclude pattern in a gitignore file. /// diff --git a/LibGit2Sharp/Index.cs b/LibGit2Sharp/Index.cs index f7e26318a..9548ceda4 100644 --- a/LibGit2Sharp/Index.cs +++ b/LibGit2Sharp/Index.cs @@ -129,7 +129,7 @@ IEnumerator IEnumerable.GetEnumerator() /// /// Promotes to the staging area the latest modifications of a file in the working directory (addition, updation or removal). - /// + /// /// If this path is ignored by configuration then it will not be staged. /// /// The path of the file within the working directory. @@ -145,7 +145,7 @@ public virtual void Stage(string path, ExplicitPathsOptions explicitPathsOptions /// /// Promotes to the staging area the latest modifications of a file in the working directory (addition, updation or removal). - /// + /// /// If this path is ignored by configuration then it will not be staged unless is unset. /// /// The path of the file within the working directory. @@ -159,7 +159,7 @@ public virtual void Stage(string path, StageOptions stageOptions = null) /// /// Promotes to the staging area the latest modifications of a collection of files in the working directory (addition, updation or removal). - /// + /// /// Any paths (even those listed explicitly) that are ignored by configuration will not be staged. /// /// The collection of paths of the files within the working directory. @@ -175,7 +175,7 @@ public virtual void Stage(IEnumerable paths, ExplicitPathsOptions explic /// /// Promotes to the staging area the latest modifications of a collection of files in the working directory (addition, updation or removal). - /// + /// /// Any paths (even those listed explicitly) that are ignored by configuration will not be staged unless is unset. /// /// The collection of paths of the files within the working directory. diff --git a/LibGit2Sharp/Mode.cs b/LibGit2Sharp/Mode.cs index b15a2a97b..b2ade9dde 100644 --- a/LibGit2Sharp/Mode.cs +++ b/LibGit2Sharp/Mode.cs @@ -8,7 +8,7 @@ public enum Mode // Inspired from http://stackoverflow.com/a/8347325/335418 /// - /// 000000 file mode (the entry doesn't exist) + /// 000000 file mode (the entry doesn't exist or is unreadable) /// Nonexistent = 0, diff --git a/LibGit2Sharp/Properties/AssemblyInfo.cs b/LibGit2Sharp/Properties/AssemblyInfo.cs index 58286cd15..4e510cf50 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.18.1")] -[assembly: AssemblyFileVersion("0.18.1")] +[assembly: AssemblyVersion("0.19.0")] +[assembly: AssemblyFileVersion("0.19.0")] diff --git a/LibGit2Sharp/Repository.cs b/LibGit2Sharp/Repository.cs index 1c583c528..6773fe503 100644 --- a/LibGit2Sharp/Repository.cs +++ b/LibGit2Sharp/Repository.cs @@ -469,7 +469,7 @@ private static string PathFromRevparseSpec(string spec) internal GitObject Lookup(string objectish, GitObjectType type, LookUpOptions lookUpOptions) { - Ensure.ArgumentNotNullOrEmptyString(objectish, "commitOrBranchSpec"); + Ensure.ArgumentNotNullOrEmptyString(objectish, "objectish"); GitObject obj; using (GitObjectSafeHandle sh = Proxy.git_revparse_single(handle, objectish)) @@ -1155,7 +1155,7 @@ public CherryPickResult CherryPick(Commit commit, Signature committer, CherryPic CherryPickResult result = null; - using (GitCheckoutOptsWrapper checkoutOptionsWrapper = new GitCheckoutOptsWrapper(options)) + using (var checkoutOptionsWrapper = new GitCheckoutOptsWrapper(options)) { var mergeOptions = new GitMergeOpts { @@ -1167,7 +1167,7 @@ public CherryPickResult CherryPick(Commit commit, Signature committer, CherryPic TargetLimit = (uint)options.TargetLimit, }; - GitCherryPickOptions gitCherryPickOpts = new GitCherryPickOptions() + var gitCherryPickOpts = new GitCherryPickOptions() { Mainline = (uint)options.Mainline, MergeOpts = mergeOptions, @@ -1175,7 +1175,7 @@ public CherryPickResult CherryPick(Commit commit, Signature committer, CherryPic CheckoutOpts = checkoutOptionsWrapper.Options, }; - Proxy.git_cherry_pick(handle, commit.Id.Oid, gitCherryPickOpts); + Proxy.git_cherrypick(handle, commit.Id.Oid, gitCherryPickOpts); if (Index.IsFullyMerged) { diff --git a/LibGit2Sharp/RepositoryExtensions.cs b/LibGit2Sharp/RepositoryExtensions.cs index 43907b767..278614dec 100644 --- a/LibGit2Sharp/RepositoryExtensions.cs +++ b/LibGit2Sharp/RepositoryExtensions.cs @@ -68,7 +68,7 @@ private static void EnsureNoGitLink() where T : GitObject /// The name of the tag to create. public static Tag ApplyTag(this IRepository repository, string tagName) { - return ApplyTag(repository, tagName, repository.Head.CanonicalName); + return repository.Tags.Add(tagName, RetrieveHeadCommit(repository)); } /// @@ -91,7 +91,16 @@ public static Tag ApplyTag(this IRepository repository, string tagName, string o /// The annotation message. public static Tag ApplyTag(this IRepository repository, string tagName, Signature tagger, string message) { - return ApplyTag(repository, tagName, repository.Head.CanonicalName, tagger, message); + return repository.Tags.Add(tagName, RetrieveHeadCommit(repository), tagger, message); + } + + private static Commit RetrieveHeadCommit(IRepository repository) + { + Commit commit = repository.Head.Tip; + + Ensure.GitObjectIsNotNull(commit, "HEAD", m => new UnbornBranchException(m)); + + return commit; } /// diff --git a/LibGit2Sharp/RevertOptions.cs b/LibGit2Sharp/RevertOptions.cs index 9b1113610..2e48f04ed 100644 --- a/LibGit2Sharp/RevertOptions.cs +++ b/LibGit2Sharp/RevertOptions.cs @@ -49,7 +49,7 @@ public RevertOptions() /// /// When reverting a merge commit, the parent number to consider as - /// mainline, starting from offset 1. + /// mainline, starting from offset 1. /// /// As a merge commit has multiple parents, reverting a merge commit /// will reverse all the changes brought in by the merge except for diff --git a/LibGit2Sharp/libgit2_hash.txt b/LibGit2Sharp/libgit2_hash.txt index 21ae06396..a34df7394 100644 --- a/LibGit2Sharp/libgit2_hash.txt +++ b/LibGit2Sharp/libgit2_hash.txt @@ -1 +1 @@ -091165c53b2bcd5d41fb71d43ed5a23a3d96bf5d +69db89342712f47ee84d9368823ec294a0db1c65 diff --git a/libgit2 b/libgit2 index 091165c53..69db89342 160000 --- a/libgit2 +++ b/libgit2 @@ -1 +1 @@ -Subproject commit 091165c53b2bcd5d41fb71d43ed5a23a3d96bf5d +Subproject commit 69db89342712f47ee84d9368823ec294a0db1c65