diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2014-05-16 16:50:41 -0400 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org <gerrit@eclipse.org> | 2014-05-16 16:50:41 -0400 |
commit | 2aa2b3af31e95b90c20794c727fc2e48b5f448e9 (patch) | |
tree | d9929ad158103487420cda5b074f510d51267e5c /org.eclipse.jgit.pgm.test | |
parent | 1350d27e904f7e016dd33cff01686e527b0d26ad (diff) | |
parent | bbf28b1cf4c7a6e2d4fdafd31b79777251d20094 (diff) | |
download | jgit-2aa2b3af31e95b90c20794c727fc2e48b5f448e9.tar.gz jgit-2aa2b3af31e95b90c20794c727fc2e48b5f448e9.zip |
Merge "Command line: implement checkout -- <path>"
Diffstat (limited to 'org.eclipse.jgit.pgm.test')
-rw-r--r-- | org.eclipse.jgit.pgm.test/src/org/eclipse/jgit/lib/CLIRepositoryTestCase.java | 4 | ||||
-rw-r--r-- | org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CheckoutTest.java | 24 |
2 files changed, 28 insertions, 0 deletions
diff --git a/org.eclipse.jgit.pgm.test/src/org/eclipse/jgit/lib/CLIRepositoryTestCase.java b/org.eclipse.jgit.pgm.test/src/org/eclipse/jgit/lib/CLIRepositoryTestCase.java index a328baec27..50ddfe04d8 100644 --- a/org.eclipse.jgit.pgm.test/src/org/eclipse/jgit/lib/CLIRepositoryTestCase.java +++ b/org.eclipse.jgit.pgm.test/src/org/eclipse/jgit/lib/CLIRepositoryTestCase.java @@ -81,6 +81,10 @@ public class CLIRepositoryTestCase extends LocalDiskRepositoryTestCase { return JGitTestUtil.writeTrashFile(db, name, data); } + protected String read(final File file) throws IOException { + return JGitTestUtil.read(file); + } + protected void deleteTrashFile(final String name) throws IOException { JGitTestUtil.deleteTrashFile(db, name); } diff --git a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CheckoutTest.java b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CheckoutTest.java index 8012893f92..2c1f59f250 100644 --- a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CheckoutTest.java +++ b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CheckoutTest.java @@ -42,6 +42,8 @@ */ package org.eclipse.jgit.pgm; +import static org.junit.Assert.assertArrayEquals; + import java.io.File; import org.eclipse.jgit.api.Git; @@ -191,4 +193,26 @@ public class CheckoutTest extends CLIRepositoryTestCase { : actual.length); Assert.assertEquals(expected, actual[0]); } + + @Test + public void testCheckoutPath() throws Exception { + Git git = new Git(db); + writeTrashFile("a", "Hello world a"); + git.add().addFilepattern(".").call(); + git.commit().setMessage("commit file a").call(); + git.branchCreate().setName("branch_1").call(); + git.checkout().setName("branch_1").call(); + File b = writeTrashFile("b", "Hello world b"); + git.add().addFilepattern("b").call(); + git.commit().setMessage("commit file b").call(); + File a = writeTrashFile("a", "New Hello world a"); + git.add().addFilepattern(".").call(); + git.commit().setMessage("modified a").call(); + assertArrayEquals(new String[] { "" }, + execute("git checkout HEAD~2 -- a")); + assertEquals("Hello world a", read(a)); + assertArrayEquals(new String[] { "* branch_1", " master", "" }, + execute("git branch")); + assertEquals("Hello world b", read(b)); + } } |