We need this constant to detect version 2 index files at read time, but we also need it to create version 2 index files. Signed-off-by: Shawn O. Pearce <spearce@xxxxxxxxxxx> --- .../src/org/spearce/jgit/lib/PackIndex.java | 3 ++- .../src/org/spearce/jgit/lib/PackIndexWriter.java | 3 +++ 2 files changed, 5 insertions(+), 1 deletions(-) diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/PackIndex.java b/org.spearce.jgit/src/org/spearce/jgit/lib/PackIndex.java index 3935d4f..ef4b13d 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/lib/PackIndex.java +++ b/org.spearce.jgit/src/org/spearce/jgit/lib/PackIndex.java @@ -42,6 +42,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; +import java.util.Arrays; import java.util.Iterator; import org.spearce.jgit.util.NB; @@ -104,7 +105,7 @@ public abstract class PackIndex implements Iterable<PackIndex.MutableEntry> { } private static boolean isTOC(final byte[] h) { - return h[0] == -1 && h[1] == 't' && h[2] == 'O' && h[3] == 'c'; + return Arrays.equals(h, PackIndexWriter.TOC); } /** diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/PackIndexWriter.java b/org.spearce.jgit/src/org/spearce/jgit/lib/PackIndexWriter.java index 473e6cf..c9b27d2 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/lib/PackIndexWriter.java +++ b/org.spearce.jgit/src/org/spearce/jgit/lib/PackIndexWriter.java @@ -55,6 +55,9 @@ import org.spearce.jgit.util.NB; * to the byte offset within the pack where the object's data can be read. */ public abstract class PackIndexWriter { + /** Magic constant indicating post-version 1 format. */ + protected static final byte[] TOC = { -1, 't', 'O', 'c' }; + /** * Create a new writer for the oldest (most widely understood) format. * <p> -- 1.5.6.74.g8a5e -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html