summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
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
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')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java18
1 files changed, 15 insertions, 3 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java
index 1f9286871f..2916c29b64 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java
@@ -533,10 +533,22 @@ public abstract class Repository {
}
if (time != null) {
String refName = new String(revChars, 0, i);
- Ref resolved = getRefDatabase().getRef(refName);
- if (resolved == null)
+ Ref ref;
+ if (refName.equals("")) {
+ // Currently checked out branch, HEAD if
+ // detached
+ ref = getRef(Constants.HEAD);
+ if (ref == null)
+ return null;
+ if (ref.isSymbolic())
+ ref = ref.getLeaf();
+ if (ref.getObjectId() == null)
+ return null;
+ } else
+ ref = getRef(refName);
+ if (ref == null)
return null;
- rev = resolveReflog(rw, resolved, time);
+ rev = resolveReflog(rw, ref, time);
i = m;
} else
i = m - 1;