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:
authorJameson Miller <jamill@microsoft.com>2014-09-07 06:15:06 +0400
committernulltoken <name@domain.com>2014-09-10 09:45:01 +0400
commit329c65204c5ece249e8b98b9d895039de58fcb94 (patch)
treecffdb6f2f2b44fd6c530b3cfc5d0a7b62f263f30 /LibGit2Sharp.Tests
parent7776cdba52e5d740677eb5eea3518c9fbf56ae75 (diff)
Revert should throw if HEAD branch is orphaned
Diffstat (limited to 'LibGit2Sharp.Tests')
-rw-r--r--LibGit2Sharp.Tests/RevertFixture.cs24
1 files changed, 24 insertions, 0 deletions
diff --git a/LibGit2Sharp.Tests/RevertFixture.cs b/LibGit2Sharp.Tests/RevertFixture.cs
index 39e64d53..13ab2c3a 100644
--- a/LibGit2Sharp.Tests/RevertFixture.cs
+++ b/LibGit2Sharp.Tests/RevertFixture.cs
@@ -434,5 +434,29 @@ namespace LibGit2Sharp.Tests
}
}
}
+
+ [Fact]
+ public void RevertOrphanedBranchThrows()
+ {
+ // The branch name to perform the revert on
+ const string revertBranchName = "refs/heads/revert";
+
+ string path = CloneRevertTestRepo();
+ using (var repo = new Repository(path))
+ {
+ // Checkout the revert branch.
+ Branch branch = repo.Checkout(revertBranchName);
+ Assert.NotNull(branch);
+
+ Commit commitToRevert = repo.Head.Tip;
+
+ // Move the HEAD to an orphaned branch.
+ repo.Refs.UpdateTarget("HEAD", "refs/heads/orphan");
+ Assert.True(repo.Info.IsHeadUnborn);
+
+ // Revert the tip of the refs/heads/revert branch.
+ Assert.Throws<UnbornBranchException>(() => repo.Revert(commitToRevert, Constants.Signature));
+ }
+ }
}
}