diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java index 2269655cf..afeaffcc9 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java @@ -79,6 +79,9 @@ public final class Constants { /** Special name for the "HEAD" symbolic-ref. */ public static final String HEAD = "HEAD"; + /** Special name for the "FETCH_HEAD" symbolic-ref. */ + public static final String FETCH_HEAD = "FETCH_HEAD"; + /** * Text string that identifies an object as a commit. *
@@ -527,6 +530,12 @@ public final class Constants {
/** name of the file containing the IDs of the parents of a merge commit */
public static final String MERGE_HEAD = "MERGE_HEAD";
+ /**
+ * name of the ref ORIG_HEAD used by certain commands to store the original
+ * value of HEAD
+ */
+ public static final String ORIG_HEAD = "ORIG_HEAD";
+
/** objectid for the empty blob */
public static final ObjectId EMPTY_BLOB_ID = ObjectId
.fromString("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391");
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java
index 21e7041b3..b2ccf2944 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java
@@ -44,6 +44,7 @@
package org.eclipse.jgit.lib;
import java.io.IOException;
+import java.util.List;
import java.util.Map;
/**
@@ -176,6 +177,19 @@ public abstract class RefDatabase {
*/
public abstract Map
+ * The result list includes non-ref items such as MERGE_HEAD and
+ * FETCH_RESULT cast to be refs. The names of these refs are not returned by
+ *
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/RefDirectory.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/RefDirectory.java
index 0f073b66f..2e4489cda 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/RefDirectory.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/RefDirectory.java
@@ -69,6 +69,8 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.text.MessageFormat;
import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
@@ -123,6 +125,10 @@ public class RefDirectory extends RefDatabase {
/** If in the header, denotes the file has peeled data. */
public static final String PACKED_REFS_PEELED = " peeled"; //$NON-NLS-1$
+ /** The names of the additional refs supported by this class */
+ private static final String[] additionalRefsNames = new String[] {
+ Constants.MERGE_HEAD, Constants.FETCH_HEAD, Constants.ORIG_HEAD };
+
private final FileRepository parent;
private final File gitDir;
@@ -297,6 +303,17 @@ public class RefDirectory extends RefDatabase {
return new RefMap(prefix, packed, upcast(loose), symbolic.toRefList());
}
+ @Override
+ public List getAdditionalRefs() throws IOException {
+ List ret = new LinkedList();
+ for (String name : additionalRefsNames) {
+ Ref r = getRef(name);
+ if (r != null)
+ ret.add(r);
+ }
+ return ret;
+ }
+
@SuppressWarnings("unchecked")
private RefList upcast(RefList extends Ref> loose) {
return (RefList) loose;
getRefs(ALL)
but are accepted by {@link #getRef(String)}
+ *
+ * @return a list of additional refs
+ * @throws IOException
+ * the reference space cannot be accessed.
+ */
+ public abstract List getAdditionalRefs() throws IOException;
+
/**
* Peel a possibly unpeeled reference by traversing the annotated tags.
*