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> --- Fixed isTOC test to return true when h.length == 8, which is always the case as it has both the TOC and the version. Also rebased into my branch: repo.or.cz:/srv/git/egit/spearce.git index-v2 With this patch in the series all tests pass again. .../src/org/spearce/jgit/lib/PackIndex.java | 6 +++++- .../src/org/spearce/jgit/lib/PackIndexWriter.java | 3 +++ 2 files changed, 8 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..c5718fa 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/lib/PackIndex.java +++ b/org.spearce.jgit/src/org/spearce/jgit/lib/PackIndex.java @@ -104,7 +104,11 @@ 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'; + final byte[] toc = PackIndexWriter.TOC; + for (int i = 0; i < toc.length; i++) + if (h[i] != toc[i]) + return false; + return true; } /** 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 -- Shawn. -- 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