Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2sharp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LibGit2Sharp.Tests/BranchFixture.cs16
-rw-r--r--LibGit2Sharp.Tests/Resources/testrepo_wd/dot_git/config3
-rw-r--r--LibGit2Sharp.Tests/Resources/testrepo_wd/dot_git/refs/heads/track-local1
-rw-r--r--LibGit2Sharp/Branch.cs5
4 files changed, 24 insertions, 1 deletions
diff --git a/LibGit2Sharp.Tests/BranchFixture.cs b/LibGit2Sharp.Tests/BranchFixture.cs
index 92d2999f..40259abc 100644
--- a/LibGit2Sharp.Tests/BranchFixture.cs
+++ b/LibGit2Sharp.Tests/BranchFixture.cs
@@ -172,7 +172,7 @@ namespace LibGit2Sharp.Tests
{
using (var repo = new Repository(StandardTestRepoWorkingDirPath))
{
- var expectedWdBranches = new[] { "master", "origin/HEAD", "origin/br2", "origin/master", "origin/packed-test", "origin/test" };
+ var expectedWdBranches = new[] { "master", "track-local", "origin/HEAD", "origin/br2", "origin/master", "origin/packed-test", "origin/test" };
CollectionAssert.AreEqual(expectedWdBranches, repo.Branches.Select(b => b.Name).ToArray());
}
@@ -186,6 +186,7 @@ namespace LibGit2Sharp.Tests
var expectedBranchesIncludingRemoteRefs = new[]
{
new { Name = "master", Sha = "32eab9cb1f450b5fe7ab663462b77d7f4b703344", IsRemote = false },
+ new { Name = "track-local", Sha = "580c2111be43802dab11328176d94c391f1deae9", IsRemote = false },
new { Name = "origin/HEAD", Sha = "580c2111be43802dab11328176d94c391f1deae9", IsRemote = true },
new { Name = "origin/br2", Sha = "a4a7dce85cf63874e984719f4fdd239f5145052f", IsRemote = true },
new { Name = "origin/master", Sha = "580c2111be43802dab11328176d94c391f1deae9", IsRemote = true },
@@ -267,6 +268,19 @@ namespace LibGit2Sharp.Tests
}
[Test]
+ public void CanGetTrackingInformationForLocalTrackingBranch()
+ {
+ using (var repo = new Repository(StandardTestRepoPath))
+ {
+ var branch = repo.Branches["track-local"];
+ branch.IsTracking.ShouldBeTrue();
+ branch.TrackedBranch.ShouldEqual(repo.Branches["master"]);
+ branch.AheadBy.ShouldEqual(2);
+ branch.BehindBy.ShouldEqual(2);
+ }
+ }
+
+ [Test]
public void CanWalkCommitsFromAnotherBranch()
{
using (var repo = new Repository(BareTestRepoPath))
diff --git a/LibGit2Sharp.Tests/Resources/testrepo_wd/dot_git/config b/LibGit2Sharp.Tests/Resources/testrepo_wd/dot_git/config
index 7e002a7d..45012594 100644
--- a/LibGit2Sharp.Tests/Resources/testrepo_wd/dot_git/config
+++ b/LibGit2Sharp.Tests/Resources/testrepo_wd/dot_git/config
@@ -12,6 +12,9 @@
[branch "master"]
remote = origin
merge = refs/heads/master
+[branch "track-local"]
+ remote = .
+ merge = refs/heads/master
[unittests]
longsetting = 15234
intsetting = 2
diff --git a/LibGit2Sharp.Tests/Resources/testrepo_wd/dot_git/refs/heads/track-local b/LibGit2Sharp.Tests/Resources/testrepo_wd/dot_git/refs/heads/track-local
new file mode 100644
index 00000000..99098dc8
--- /dev/null
+++ b/LibGit2Sharp.Tests/Resources/testrepo_wd/dot_git/refs/heads/track-local
@@ -0,0 +1 @@
+580c2111be43802dab11328176d94c391f1deae9
diff --git a/LibGit2Sharp/Branch.cs b/LibGit2Sharp/Branch.cs
index fdfd74fb..f5e86de2 100644
--- a/LibGit2Sharp/Branch.cs
+++ b/LibGit2Sharp/Branch.cs
@@ -187,6 +187,11 @@ namespace LibGit2Sharp
private static string ResolveTrackedReference(string trackedRemote, string trackedRefName)
{
+ if (trackedRemote == ".")
+ {
+ return trackedRefName;
+ }
+
//TODO: To be replaced by native libgit2 git_branch_tracked_reference() when available.
return trackedRefName.Replace("refs/heads/", string.Concat("refs/remotes/", trackedRemote, "/"));
}