aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorRobin Stocker <robin@nibor.org>2014-01-14 17:38:40 +0100
committerRobin Stocker <robin@nibor.org>2014-01-14 17:45:50 +0100
commitc096b42e3e6714f3df3dec317cf1826c43734eb1 (patch)
tree00a6a499b410b3f9b680691e5a2639dfad23e984 /org.eclipse.jgit.test
parent0a38e08c1c7c676116bffaaa8c32b38337597903 (diff)
downloadjgit-c096b42e3e6714f3df3dec317cf1826c43734eb1.tar.gz
jgit-c096b42e3e6714f3df3dec317cf1826c43734eb1.zip
Add setContains to ListBranchCommand (branch --contains)
To correspond to the behavior of "git branch", also return HEAD in case it is detached. Bug: 425678 Change-Id: Ie615731434d70b99bd18c7a02e832c0a2c3ceef3 Signed-off-by: Robin Stocker <robin@nibor.org>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BranchCommandTest.java14
1 files changed, 14 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BranchCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BranchCommandTest.java
index 91ced0a596..c0e2e2ca8a 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BranchCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BranchCommandTest.java
@@ -197,6 +197,20 @@ public class BranchCommandTest extends RepositoryTestCase {
}
@Test
+ public void testListBranchesWithContains() throws Exception {
+ git.branchCreate().setName("foo").setStartPoint(secondCommit).call();
+
+ List<Ref> refs = git.branchList().call();
+ assertEquals(2, refs.size());
+
+ List<Ref> refsContainingSecond = git.branchList()
+ .setContains(secondCommit.name()).call();
+ assertEquals(1, refsContainingSecond.size());
+ // master is on initial commit, so it should not be returned
+ assertEquals("refs/heads/foo", refsContainingSecond.get(0).getName());
+ }
+
+ @Test
public void testCreateFromCommit() throws Exception {
Ref branch = git.branchCreate().setName("FromInitial").setStartPoint(
initialCommit).call();