Browse Source

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
tags/v4.2.0.201601211800-r
Shawn Pearce 8 years ago
parent
commit
398d8e877f

+ 4
- 4
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/RefTree.java View File

@@ -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$

/**

+ 2
- 2
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/Scanner.java View File

@@ -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) {

Loading…
Cancel
Save