summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm.test/tst/org/eclipse
diff options
context:
space:
mode:
authorTomasz Zarna <tomasz.zarna@tasktop.com>2012-11-04 21:57:12 +0100
committerChris Aniszczyk <zx@twitter.com>2012-11-15 16:05:09 -0800
commit790126c1457fba6c85680dc7858b4c84e84ea640 (patch)
tree709fce6cf789c6c5b30386e735100c58e7e9ec44 /org.eclipse.jgit.pgm.test/tst/org/eclipse
parent074f9194dc5c4ad4987f7ec6f956c7da7d80702c (diff)
downloadjgit-790126c1457fba6c85680dc7858b4c84e84ea640.tar.gz
jgit-790126c1457fba6c85680dc7858b4c84e84ea640.zip
Do not fail when checking out HEAD
Change-Id: I99f5467477ed53101121a5a5d8a0910c55758401 Signed-off-by: Chris Aniszczyk <zx@twitter.com>
Diffstat (limited to 'org.eclipse.jgit.pgm.test/tst/org/eclipse')
-rw-r--r--org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CheckoutTest.java23
1 files changed, 20 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 d7b91cc51a..48cb5c54ca 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
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012, IBM Corporation and others.
+ * Copyright (C) 2012, IBM Corporation
* and other copyright owners as documented in the project's IP log.
*
* This program and the accompanying materials are made available
@@ -93,9 +93,26 @@ public class CheckoutTest extends CLIRepositoryTestCase {
execute("git checkout -b side"));
}
+ @Test
+ public void testCheckoutUnresolvedHead() throws Exception {
+ assertEquals(
+ "error: pathspec 'HEAD' did not match any file(s) known to git.",
+ execute("git checkout HEAD"));
+ }
+
+ @Test
+ public void testCheckoutHead() throws Exception {
+ new Git(db).commit().setMessage("initial commit").call();
+
+ assertEquals("", execute("git checkout HEAD"));
+ }
+
static private void assertEquals(String expected, String[] actual) {
- Assert.assertEquals(actual[actual.length - 1].equals("") ? 2 : 1,
- actual.length); // ignore last line if empty
+ // if there is more than one line, ignore last one if empty
+ Assert.assertEquals(
+ 1,
+ actual.length > 1 && actual[actual.length - 1].equals("") ? actual.length - 1
+ : actual.length);
Assert.assertEquals(expected, actual[0]);
}
}