Skip to content

Release v0.19 #798

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 27, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,37 @@
- CodeBetter TeamCity: <http://teamcity.codebetter.com/project.html?projectId=LibGit2Sharp&guest=1>
- Travis: <https://travis-ci.org/libgit2/libgit2sharp>

## 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
Expand Down
Binary file removed Lib/NativeBinaries/amd64/git2-091165c.dll
Binary file not shown.
Binary file removed Lib/NativeBinaries/amd64/git2-091165c.pdb
Binary file not shown.
Binary file added Lib/NativeBinaries/amd64/git2-69db893.dll
Binary file not shown.
Binary file added Lib/NativeBinaries/amd64/git2-69db893.pdb
Binary file not shown.
Binary file removed Lib/NativeBinaries/x86/git2-091165c.dll
Binary file not shown.
Binary file removed Lib/NativeBinaries/x86/git2-091165c.pdb
Binary file not shown.
Binary file added Lib/NativeBinaries/x86/git2-69db893.dll
Binary file not shown.
Binary file added Lib/NativeBinaries/x86/git2-69db893.pdb
Binary file not shown.
8 changes: 8 additions & 0 deletions LibGit2Sharp.Tests/CloneFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<InvalidSpecificationException>(() => Repository.Clone("http://github.com", scd.DirectoryPath));
}
}
}
72 changes: 0 additions & 72 deletions LibGit2Sharp.Tests/ConfigurationFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>("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<string>("user.name"));
}
}

[Fact]
public void CanReadBooleanValue()
{
Expand Down Expand Up @@ -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<string>("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<string>("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()
{
Expand Down
2 changes: 1 addition & 1 deletion LibGit2Sharp.Tests/MergeFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion LibGit2Sharp.Tests/ObjectDatabaseFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
4 changes: 2 additions & 2 deletions LibGit2Sharp.Tests/OdbBackendFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion LibGit2Sharp.Tests/RepositoryFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion LibGit2Sharp.Tests/ResetHeadFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void ResetANewlyInitializedRepositoryThrows(bool isBare)

using (var repo = new Repository(repoPath))
{
Assert.Throws<LibGit2SharpException>(() => repo.Reset(ResetMode.Soft));
Assert.Throws<UnbornBranchException>(() => repo.Reset(ResetMode.Soft));
}
}

Expand Down
2 changes: 1 addition & 1 deletion LibGit2Sharp.Tests/ResetIndexFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void ResetANewlyInitializedNonBareRepositoryThrows()

using (var repo = new Repository(repoPath))
{
Assert.Throws<LibGit2SharpException>(() => repo.Reset());
Assert.Throws<UnbornBranchException>(() => repo.Reset());
}
}

Expand Down
4 changes: 0 additions & 4 deletions LibGit2Sharp.Tests/StatusFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}
Expand Down
27 changes: 24 additions & 3 deletions LibGit2Sharp.Tests/TagFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public void CreatingATagInAEmptyRepositoryThrows()

using (var repo = new Repository(repoPath))
{
Assert.Throws<LibGit2SharpException>(() => repo.ApplyTag("mynotag"));
Assert.Throws<UnbornBranchException>(() => repo.ApplyTag("mynotag"));
}
}

Expand All @@ -246,7 +246,8 @@ public void CreatingATagForHeadInAEmptyRepositoryThrows()

using (var repo = new Repository(repoPath))
{
Assert.Throws<LibGit2SharpException>(() => repo.ApplyTag("mytaghead", "HEAD"));
Assert.Throws<UnbornBranchException>(() => repo.ApplyTag("mytaghead", "HEAD"));
Assert.Throws<UnbornBranchException>(() => repo.ApplyTag("mytaghead"));
}
}

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -364,7 +385,7 @@ public void CanReadTagWithoutTagger()

Tree tree = repo.Lookup<Tree>("581f9824ecaf824221bd36edf5430f2739a7c4f5");
Assert.NotNull(tree);

Assert.Equal(tree.Id, tag.Target.Id);
}
}
Expand Down
5 changes: 5 additions & 0 deletions LibGit2Sharp/ChangeKind.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,10 @@ public enum ChangeKind
/// of the file was changed.
/// </summary>
TypeChanged = 8,

/// <summary>
/// Entry is unreadable.
/// </summary>
Unreadable = 9,
}
}
2 changes: 1 addition & 1 deletion LibGit2Sharp/CherryPickOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public CherryPickOptions()

/// <summary>
/// When cherry picking a merge commit, the parent number to consider as
/// mainline, starting from offset 1.
/// mainline, starting from offset 1.
/// <para>
/// As a merge commit has multiple parents, cherry picking a merge commit
/// will reverse all the changes brought in by the merge except for
Expand Down
21 changes: 20 additions & 1 deletion LibGit2Sharp/Core/Ensure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,32 @@ public static void ArgumentConformsTo<T>(T argumentValue, Func<T, bool> checker,
}

public static void GitObjectIsNotNull(GitObject gitObject, string identifier)
{
Func<string, LibGit2SharpException> exceptionBuilder;

if (string.Equals("HEAD", identifier, StringComparison.Ordinal))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a microoptimization, I'd probably do the gitObject != null check before deciding what type of exception to throw.

{
exceptionBuilder = m => new UnbornBranchException(m);
}
else
{
exceptionBuilder = m => new LibGit2SharpException(m);
}

GitObjectIsNotNull(gitObject, identifier, exceptionBuilder);
}

public static void GitObjectIsNotNull(
GitObject gitObject,
string identifier,
Func<string, LibGit2SharpException> 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.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest using a different message when throwing an UnbornBranchException: "No valid git object identified by 'HEAD' exists" doesn't really explain that (relatively common) situation very well.

identifier));
}
Expand Down
10 changes: 10 additions & 0 deletions LibGit2Sharp/Core/GitDiff.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,16 @@ internal enum GitDiffOptionFlags
/// </summary>
GIT_DIFF_UPDATE_INDEX = (1 << 15),

/// <summary>
/// Include unreadable files in the diff
/// </summary>
GIT_DIFF_INCLUDE_UNREADABLE = (1 << 16),

/// <summary>
/// Include unreadable files in the diff
/// </summary>
GIT_DIFF_INCLUDE_UNREADABLE_AS_UNTRACKED = (1 << 17),

/*
* Options controlling how output will be generated
*/
Expand Down
2 changes: 2 additions & 0 deletions LibGit2Sharp/Core/GitStatusOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,7 @@ internal enum GitStatusOptionFlags
RenamesFromRewrites = (1 << 11),
NoRefresh = (1 << 12),
UpdateIndex = (1 << 13),
IncludeUnreadable = (1 << 14),
IncludeUnreadableAsUntracked = (1 << 15),
}
}
2 changes: 1 addition & 1 deletion LibGit2Sharp/Core/NativeDllName.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ namespace LibGit2Sharp.Core
{
internal static class NativeDllName
{
public const string Name = "git2-091165c";
public const string Name = "git2-69db893";
}
}
2 changes: 1 addition & 1 deletion LibGit2Sharp/Core/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions LibGit2Sharp/Core/Proxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
}
Expand Down
Loading