aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Pearce <spearce@spearce.org>2016-01-09 17:27:25 -0800
committerShawn Pearce <spearce@spearce.org>2016-01-11 15:27:14 -0800
commit398d8e877f91216e287a7a569ea758062dd7c521 (patch)
tree287b7bc065637bf751aae58da989acfef3323c85
parent088c2fc6e33737a406e69a99d75f06d3fbb05e30 (diff)
downloadjgit-398d8e877f91216e287a7a569ea758062dd7c521.tar.gz
jgit-398d8e877f91216e287a7a569ea758062dd7c521.zip
RefTree: Change peel suffix to " ^" (space carrot)
Using ^{} as the peel suffix has caused problems when projects used tags like v2.1 and then v2.1.1, v2.2.2, etc. The peeled value for v2.1 was stored very far away in the tree relative to v2.1 itself as ^ sorts in the ASCII/UTF-8 encoding after all other common tag characters like digits and dots. Use " ^" instead as space is not valid in a reference name, sorts before all other valid reference characters (thus forcing next entry locality) and this looks like a peeled marker for the prior tag. Change-Id: I26d2247a0428dfe26a9c319c02159502b3a67455
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/RefTree.java8
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/Scanner.java4
2 files changed, 6 insertions, 6 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/RefTree.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/RefTree.java
index 66c0be6764..43eec5185b 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/RefTree.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/RefTree.java
@@ -100,15 +100,15 @@ import org.eclipse.jgit.util.RawParseUtils;
* blob storing the name of the target reference.
* <p>
* Annotated tags also store the peeled object using a {@code GITLINK} entry
- * with the suffix <code>"^{}"</code>, for example {@code "tags/v1.0"} stores
- * the annotated tag object, while <code>"tags/v1.0^{}"</code> stores the commit
- * the tag annotates.
+ * with the suffix <code>" ^"</code> (space carrot), for example
+ * {@code "tags/v1.0"} stores the annotated tag object, while
+ * <code>"tags/v1.0 ^"</code> stores the commit the tag annotates.
* <p>
* {@code HEAD} is a special case and stored as {@code "..HEAD"}.
*/
public class RefTree {
/** Suffix applied to GITLINK to indicate its the peeled value of a tag. */
- public static final String PEELED_SUFFIX = "^{}"; //$NON-NLS-1$
+ public static final String PEELED_SUFFIX = " ^"; //$NON-NLS-1$
static final String ROOT_DOTDOT = ".."; //$NON-NLS-1$
/**
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/Scanner.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/Scanner.java
index b3aeed0df3..d383abf316 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/Scanner.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/Scanner.java
@@ -230,7 +230,7 @@ class Scanner {
private static boolean curElementHasPeelSuffix(AbstractTreeIterator itr) {
int n = itr.getEntryPathLength();
byte[] c = itr.getEntryPathBuffer();
- return n > 3 && c[n - 3] == '^' && c[n - 2] == '{' && c[n - 1] == '}';
+ return n > 2 && c[n - 2] == ' ' && c[n - 1] == '^';
}
private static void peel(RefList.Builder<Ref> all, CanonicalTreeParser p) {
@@ -272,7 +272,7 @@ class Scanner {
byte[] buf = p.getEntryPathBuffer();
int len = p.getEntryPathLength();
if (peel) {
- len -= 3;
+ len -= 2;
}
int ptr = 0;
if (RawParseUtils.match(buf, ptr, REFS_DOT_DOT) > 0) {