summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CheckoutTest.java25
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Checkout.java9
2 files changed, 31 insertions, 3 deletions
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 3651542fc6..4b86b6014e 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
@@ -613,7 +613,30 @@ public class CheckoutTest extends CLIRepositoryTestCase {
}
@Test
- public void testCheckouSingleFile() throws Exception {
+ public void testCheckoutAllPaths() throws Exception {
+ try (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 -- ."));
+ assertEquals("Hello world a", read(a));
+ assertArrayEquals(new String[] { "* branch_1", " master", "" },
+ execute("git branch"));
+ assertEquals("Hello world b", read(b));
+ }
+ }
+
+ @Test
+ public void testCheckoutSingleFile() throws Exception {
try (Git git = new Git(db)) {
File a = writeTrashFile("a", "file a");
git.add().addFilepattern(".").call();
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Checkout.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Checkout.java
index 94517dbf2f..629b47a9a0 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Checkout.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Checkout.java
@@ -92,8 +92,13 @@ class Checkout extends TextBuiltin {
CheckoutCommand command = git.checkout();
if (paths.size() > 0) {
command.setStartPoint(name);
- for (String path : paths)
- command.addPath(path);
+ if (paths.size() == 1 && paths.get(0).equals(".")) { //$NON-NLS-1$
+ command.setAllPaths(true);
+ } else {
+ for (String path : paths) {
+ command.addPath(path);
+ }
+ }
} else {
command.setCreateBranch(createBranch);
command.setName(name);