diff options
author | Robin Stocker <robin@nibor.org> | 2014-01-14 17:46:26 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2014-03-07 18:24:42 -0500 |
commit | 31fec678d858bc6fa6456ac7e6ec2d77bf1f6f99 (patch) | |
tree | 332b44732477f70fcce42ffe194b23320f64f995 /org.eclipse.jgit.pgm.test | |
parent | f6f3fe46fcdc0f76bc5b50efa18176510ccb5503 (diff) | |
download | jgit-31fec678d858bc6fa6456ac7e6ec2d77bf1f6f99.tar.gz jgit-31fec678d858bc6fa6456ac7e6ec2d77bf1f6f99.zip |
Implement "git branch --contains" in pgm
Bug: 425678
Change-Id: Ib59e05a0bde58562cc61e6e3000df761660b468e
Signed-off-by: Robin Stocker <robin@nibor.org>
Diffstat (limited to 'org.eclipse.jgit.pgm.test')
-rw-r--r-- | org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/BranchTest.java | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/BranchTest.java b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/BranchTest.java index 5193aaa42d..4200cd05cf 100644 --- a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/BranchTest.java +++ b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/BranchTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012, IBM Corporation and others. + * Copyright (C) 2012, 2014 IBM Corporation and others. * and other copyright owners as documented in the project's IP log. * * This program and the accompanying materials are made available @@ -46,6 +46,9 @@ import static org.junit.Assert.assertEquals; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.lib.CLIRepositoryTestCase; +import org.eclipse.jgit.lib.Constants; +import org.eclipse.jgit.lib.RefUpdate; +import org.eclipse.jgit.revwalk.RevCommit; import org.junit.Before; import org.junit.Test; @@ -64,6 +67,26 @@ public class BranchTest extends CLIRepositoryTestCase { } @Test + public void testListDetached() throws Exception { + RefUpdate updateRef = db.updateRef(Constants.HEAD, true); + updateRef.setNewObjectId(db.resolve("6fd41be")); + updateRef.update(); + assertEquals("* (no branch) 6fd41be initial commit", + execute("git branch -v")[0]); + } + + @Test + public void testListContains() throws Exception { + new Git(db).branchCreate().setName("initial").call(); + RevCommit second = new Git(db).commit().setMessage("second commit") + .call(); + assertArrayOfLinesEquals(new String[] { " initial", "* master", "" }, + execute("git branch --contains 6fd41be")); + assertArrayOfLinesEquals(new String[] { "* master", "" }, + execute("git branch --contains " + second.name())); + } + + @Test public void testExistingBranch() throws Exception { assertEquals("fatal: A branch named 'master' already exists.", execute("git branch master")[0]); |