summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorShawn Pearce <spearce@spearce.org>2016-01-15 12:46:33 -0800
committerShawn Pearce <spearce@spearce.org>2016-01-15 12:46:33 -0800
commitbbfca06d64616c13eb0281816149c8cc6d872023 (patch)
treec86f4c6dfefac7d6f82673ed21d211dc1c2f7690 /org.eclipse.jgit
parenta290b822ab4f0ec9c1e5121235564fadf594a74e (diff)
downloadjgit-bbfca06d64616c13eb0281816149c8cc6d872023.tar.gz
jgit-bbfca06d64616c13eb0281816149c8cc6d872023.zip
RefTreeDatabase: Allow ORIG_HEAD, etc. on non-bare repositories
Store these in the bootstrap layer where they are using $GIT_DIR as the storage directory for any reference that does not contain '/'. Change-Id: I5595bf514e4475b7c7e799c2c79446597a3abb4a
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/RefTreeDatabase.java23
1 files changed, 20 insertions, 3 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/RefTreeDatabase.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/RefTreeDatabase.java
index f6fdef1fa5..df93ce88af 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/RefTreeDatabase.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/RefTreeDatabase.java
@@ -43,6 +43,7 @@
package org.eclipse.jgit.internal.storage.reftree;
+import static org.eclipse.jgit.lib.Constants.HEAD;
import static org.eclipse.jgit.lib.Ref.Storage.LOOSE;
import static org.eclipse.jgit.lib.Ref.Storage.PACKED;
@@ -189,12 +190,19 @@ public class RefTreeDatabase extends RefDatabase {
@Override
public Ref getRef(String name) throws IOException {
- return findRef(getRefs(ALL), name);
+ String[] needle = new String[SEARCH_PATH.length];
+ for (int i = 0; i < SEARCH_PATH.length; i++) {
+ needle[i] = SEARCH_PATH[i] + name;
+ }
+ return firstExactRef(needle);
}
@Override
public Ref exactRef(String name) throws IOException {
- if (conflictsWithBootstrap(name)) {
+ if (!repo.isBare() && name.indexOf('/') < 0 && !HEAD.equals(name)) {
+ // Pass through names like MERGE_HEAD, ORIG_HEAD, FETCH_HEAD.
+ return bootstrap.exactRef(name);
+ } else if (conflictsWithBootstrap(name)) {
return null;
}
@@ -311,6 +319,9 @@ public class RefTreeDatabase extends RefDatabase {
@Override
public RefUpdate newUpdate(String name, boolean detach) throws IOException {
+ if (!repo.isBare() && name.indexOf('/') < 0 && !HEAD.equals(name)) {
+ return bootstrap.newUpdate(name, detach);
+ }
if (conflictsWithBootstrap(name)) {
return new AlwaysFailUpdate(this, name);
}
@@ -345,7 +356,13 @@ public class RefTreeDatabase extends RefDatabase {
return true;
} else if (txnCommitted.equals(name)) {
return true;
- } else if (name.length() > txnCommitted.length()
+ }
+
+ if (name.indexOf('/') < 0 && !HEAD.equals(name)) {
+ return true;
+ }
+
+ if (name.length() > txnCommitted.length()
&& name.charAt(txnCommitted.length()) == '/'
&& name.startsWith(txnCommitted)) {
return true;