Skip to content

Commit 4206860

Browse files
committed
Add unit test for #1782
This unit test demonstrates the exception that was reported in #1782.
1 parent 4de700f commit 4206860

17 files changed

+61
-0
lines changed

LibGit2Sharp.Tests/BranchFixture.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,39 @@ public void CanUnsetTrackedBranch()
879879
}
880880
}
881881

882+
[Fact]
883+
public void CanSetTrackedBranch_MultipleFetchSpecs()
884+
{
885+
const string testBranchName = "master";
886+
const string trackedBranchName = "refs/remotes/origin/master";
887+
888+
string path = SandboxMultiFetchSpecTestRepo();
889+
using (var repo = new Repository(path))
890+
{
891+
Branch trackedBranch = repo.Branches[trackedBranchName];
892+
Assert.True(trackedBranch.IsRemote);
893+
894+
Branch branch = repo.CreateBranch(testBranchName, trackedBranch.Tip);
895+
Assert.False(branch.IsTracking);
896+
897+
repo.Branches.Update(branch,
898+
b => b.TrackedBranch = trackedBranch.CanonicalName);
899+
900+
// Verify the immutability of the branch.
901+
Assert.False(branch.IsTracking);
902+
903+
// Get the updated branch information.
904+
branch = repo.Branches[testBranchName];
905+
906+
Remote upstreamRemote = repo.Network.Remotes["origin"];
907+
Assert.NotNull(upstreamRemote);
908+
909+
Assert.True(branch.IsTracking);
910+
Assert.Equal(trackedBranch, branch.TrackedBranch);
911+
Assert.Equal("origin", branch.RemoteName);
912+
}
913+
}
914+
882915
[Fact]
883916
public void CanWalkCommitsFromBranch()
884917
{
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is another file

LibGit2Sharp.Tests/Resources/multifetchspec_testrepo_wd/dot_git/FETCH_HEAD

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ref: refs/heads/PR-28
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[core]
2+
repositoryformatversion = 0
3+
filemode = false
4+
bare = false
5+
logallrefupdates = true
6+
ignorecase = true
7+
[remote "origin"]
8+
url = ../multifetchspec_testrepo.git/
9+
fetch = +refs/pull/28/head:refs/remotes/origin/PR-28
10+
fetch = +refs/heads/master:refs/remotes/origin/master
11+
fetch = +refs/heads/*:refs/remotes/origin/*
12+
[branch "PR-28"]
13+
remote = origin
14+
merge = refs/pull/28/head
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
x+)JMU�0f040031Qp��/�H-r��I�+�(a(�X�y��ޟ��k֟8iS��6Ti^jy|L�+W���'����xg�f���m;|I %�

0 commit comments

Comments
 (0)