summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2012-09-03 02:52:41 -0400
committerGerrit Code Review @ Eclipse.org <gerrit@eclipse.org>2012-09-03 02:52:41 -0400
commit9d3110e72d943bae6139d4ddfc3ebd6e9d00b0e8 (patch)
tree7ebc6648a6bbbb85fc89fb70eee6c7eb76f79779 /org.eclipse.jgit.test
parent51c20b27acdef57dcb1d79ac995cd49f2e9c2f91 (diff)
parent11533f5d1de16496ad44abd70dd8d7fbe176bbbf (diff)
downloadjgit-9d3110e72d943bae6139d4ddfc3ebd6e9d00b0e8.tar.gz
jgit-9d3110e72d943bae6139d4ddfc3ebd6e9d00b0e8.zip
Merge "Add tests for more coverage of CheckoutCommand"
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java65
1 files changed, 65 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java
index dc9303aecf..b75d0bdc4c 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java
@@ -43,6 +43,8 @@
*/
package org.eclipse.jgit.api;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@@ -235,6 +237,69 @@ public class CheckoutCommandTest extends RepositoryTestCase {
}
@Test
+ public void testCheckoutOfDirectoryShouldBeRecursive() throws Exception {
+ File a = writeTrashFile("dir/a.txt", "A");
+ File b = writeTrashFile("dir/sub/b.txt", "B");
+ git.add().addFilepattern("dir").call();
+ git.commit().setMessage("Added dir").call();
+
+ write(a, "modified");
+ write(b, "modified");
+ git.checkout().addPath("dir").call();
+
+ assertThat(read(a), is("A"));
+ assertThat(read(b), is("B"));
+ }
+
+ @Test
+ public void testCheckoutAllPaths() throws Exception {
+ File a = writeTrashFile("dir/a.txt", "A");
+ File b = writeTrashFile("dir/sub/b.txt", "B");
+ git.add().addFilepattern("dir").call();
+ git.commit().setMessage("Added dir").call();
+
+ write(a, "modified");
+ write(b, "modified");
+ git.checkout().setAllPaths(true).call();
+
+ assertThat(read(a), is("A"));
+ assertThat(read(b), is("B"));
+ }
+
+ @Test
+ public void testCheckoutWithStartPoint() throws Exception {
+ File a = writeTrashFile("a.txt", "A");
+ git.add().addFilepattern("a.txt").call();
+ RevCommit first = git.commit().setMessage("Added a").call();
+
+ write(a, "other");
+ git.commit().setAll(true).setMessage("Other").call();
+
+ git.checkout().setCreateBranch(true).setName("a")
+ .setStartPoint(first.getId().getName()).call();
+
+ assertThat(read(a), is("A"));
+ }
+
+ @Test
+ public void testCheckoutWithStartPointOnlyCertainFiles() throws Exception {
+ File a = writeTrashFile("a.txt", "A");
+ File b = writeTrashFile("b.txt", "B");
+ git.add().addFilepattern("a.txt").addFilepattern("b.txt").call();
+ RevCommit first = git.commit().setMessage("First").call();
+
+ write(a, "other");
+ write(b, "other");
+ git.commit().setAll(true).setMessage("Other").call();
+
+ git.checkout().setCreateBranch(true).setName("a")
+ .setStartPoint(first.getId().getName()).addPath("a.txt").call();
+
+ assertThat(read(a), is("A"));
+ assertThat(read(b), is("other"));
+ }
+
+ @Test
public void testDetachedHeadOnCheckout() throws JGitInternalException,
IOException, GitAPIException {
CheckoutCommand co = git.checkout();