Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/lib/RefWriter.java')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/RefWriter.java33
1 files changed, 26 insertions, 7 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefWriter.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefWriter.java
index c48449933b..6b0c7b3a98 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefWriter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefWriter.java
@@ -49,6 +49,10 @@ package org.eclipse.jgit.lib;
import java.io.IOException;
import java.io.StringWriter;
import java.util.Collection;
+import java.util.Map;
+
+import org.eclipse.jgit.util.RefList;
+import org.eclipse.jgit.util.RefMap;
/**
* Writes out refs to the {@link Constants#INFO_REFS} and
@@ -71,6 +75,22 @@ public abstract class RefWriter {
}
/**
+ * @param refs
+ * the complete set of references. This should have been computed
+ * by applying updates to the advertised refs already discovered.
+ */
+ public RefWriter(Map<String, Ref> refs) {
+ if (refs instanceof RefMap)
+ this.refs = refs.values();
+ else
+ this.refs = RefComparator.sort(refs.values());
+ }
+
+ RefWriter(RefList<Ref> list) {
+ this.refs = list.asList();
+ }
+
+ /**
* Rebuild the {@link Constants#INFO_REFS}.
* <p>
* This method rebuilds the contents of the {@link Constants#INFO_REFS} file
@@ -85,7 +105,7 @@ public abstract class RefWriter {
final StringWriter w = new StringWriter();
final char[] tmp = new char[Constants.OBJECT_ID_STRING_LENGTH];
for (final Ref r : refs) {
- if (Constants.HEAD.equals(r.getOrigName())) {
+ if (Constants.HEAD.equals(r.getName())) {
// Historically HEAD has never been published through
// the INFO_REFS file. This is a mistake, but its the
// way things are.
@@ -121,19 +141,18 @@ public abstract class RefWriter {
*/
public void writePackedRefs() throws IOException {
boolean peeled = false;
-
for (final Ref r : refs) {
- if (r.getStorage() != Ref.Storage.PACKED)
- continue;
- if (r.getPeeledObjectId() != null)
+ if (r.getStorage().isPacked() && r.isPeeled()) {
peeled = true;
+ break;
+ }
}
final StringWriter w = new StringWriter();
if (peeled) {
- w.write("# pack-refs with:");
+ w.write(RefDirectory.PACKED_REFS_HEADER);
if (peeled)
- w.write(" peeled");
+ w.write(RefDirectory.PACKED_REFS_PEELED);
w.write('\n');
}

Back to the top