aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorRobin Rosenberg <robin.rosenberg@dewire.com>2012-07-16 23:47:46 +0200
committerRobin Rosenberg <robin.rosenberg@dewire.com>2012-07-16 23:56:51 +0200
commitf82d1cb5c0ee593eb7a68b2d9ea539399f9204ba (patch)
treebdb388a87347771f3f75d5d690560c31597ae50f /org.eclipse.jgit.test
parent981720d15080f37f37dbc37776c1f2d1ef242cb4 (diff)
downloadjgit-f82d1cb5c0ee593eb7a68b2d9ea539399f9204ba.tar.gz
jgit-f82d1cb5c0ee593eb7a68b2d9ea539399f9204ba.zip
Allow a @ without branch in revision syntax
No branch before @ is interpreted as the currently checked out branch. For detached heads it would be HEAD, but normally it is the branch that HEAD refers to. Change-Id: I051a1724fa390b8212e8986ba832b1347a20371e
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ReflogResolveTest.java32
1 files changed, 32 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ReflogResolveTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ReflogResolveTest.java
index c3de79b6c4..15cbbcbdf0 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ReflogResolveTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ReflogResolveTest.java
@@ -72,6 +72,38 @@ public class ReflogResolveTest extends RepositoryTestCase {
}
@Test
+ public void resolveUnnamedCurrentBranchCommits() throws Exception {
+ Git git = new Git(db);
+ writeTrashFile("file.txt", "content");
+ git.add().addFilepattern("file.txt").call();
+ RevCommit c1 = git.commit().setMessage("create file").call();
+ writeTrashFile("file.txt", "content2");
+ git.add().addFilepattern("file.txt").call();
+ RevCommit c2 = git.commit().setMessage("edit file").call();
+
+ assertEquals(c2, db.resolve("master@{0}"));
+ assertEquals(c1, db.resolve("master@{1}"));
+
+ git.checkout().setCreateBranch(true).setName("newbranch")
+ .setStartPoint(c1).call();
+
+ // same as current branch, e.g. master
+ assertEquals(c1, db.resolve("@{0}"));
+ try {
+ assertEquals(c1, db.resolve("@{1}"));
+ fail(); // Looking at wrong ref, e.g HEAD
+ } catch (RevisionSyntaxException e) {
+ assertNotNull(e);
+ }
+
+ // detached head, read HEAD reflog
+ git.checkout().setName(c2.getName()).call();
+ assertEquals(c2, db.resolve("@{0}"));
+ assertEquals(c1, db.resolve("@{1}"));
+ assertEquals(c2, db.resolve("@{2}"));
+ }
+
+ @Test
public void resolveReflogParent() throws Exception {
Git git = new Git(db);
writeTrashFile("file.txt", "content");