summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorRobin Stocker2012-09-03 02:44:28 (EDT)
committer Matthias Sohn2012-09-03 02:44:28 (EDT)
commit11533f5d1de16496ad44abd70dd8d7fbe176bbbf (patch)
treee843df9217f9c32acbff039e459106a357e36b4c
parent0a9e010e14c96d97e902bf3c46ac1487ed6fbc18 (diff)
downloadjgit-11533f5d1de16496ad44abd70dd8d7fbe176bbbf.zip
jgit-11533f5d1de16496ad44abd70dd8d7fbe176bbbf.tar.gz
jgit-11533f5d1de16496ad44abd70dd8d7fbe176bbbf.tar.bz2
Add tests for more coverage of CheckoutCommandrefs/changes/00/7200/2
Change-Id: Id3ab5f56f88d7e9636c71b30258c268a75fc422e Signed-off-by: Robin Stocker <robin@nibor.org> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-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 dc9303a..b75d0bd 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();