From: "Shawn O. Pearce" <spearce@spearce.org>
To: Robin Rosenberg <robin.rosenberg@dewire.com>,
Marek Zawirski <marek.zawirski@gmail.com>
Cc: git@vger.kernel.org
Subject: [JGIT PATCH 06/10 v2] Reuse the magic tOc constant for pack index headers
Date: Wed, 25 Jun 2008 00:01:48 -0400 [thread overview]
Message-ID: <20080625040148.GZ11793@spearce.org> (raw)
In-Reply-To: <1214273408-70793-7-git-send-email-spearce@spearce.org>
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@spearce.org>
---
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.
next prev parent reply other threads:[~2008-06-25 4:03 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-24 2:09 [JGIT PATCH 00/10] Support writing pack index version 2 Shawn O. Pearce
2008-06-24 2:09 ` [JGIT PATCH 01/10] Extract inner ObjectEntry from IndexPack class Shawn O. Pearce
2008-06-24 2:10 ` [JGIT PATCH 02/10] Make ObjectEntry's position field private Shawn O. Pearce
2008-06-24 2:10 ` [JGIT PATCH 03/10] Rename ObjectEntry to PackedObjectInfo Shawn O. Pearce
2008-06-24 2:10 ` [JGIT PATCH 04/10] Document PackedObjectInfo and make it public for reuse Shawn O. Pearce
2008-06-24 2:10 ` [JGIT PATCH 05/10] Refactor pack index writing to a common API Shawn O. Pearce
2008-06-24 2:10 ` [JGIT PATCH 06/10] Reuse the magic tOc constant for pack index headers Shawn O. Pearce
2008-06-24 2:10 ` [JGIT PATCH 07/10] Add 64 bit network byte order encoding to NB Shawn O. Pearce
2008-06-24 2:10 ` [JGIT PATCH 08/10] Compute packed object entry CRC32 data during IndexPack Shawn O. Pearce
2008-06-24 2:10 ` [JGIT PATCH 09/10] Add support for writing pack index v2 files Shawn O. Pearce
2008-06-24 2:10 ` [JGIT PATCH 10/10] Default IndexPack to honor pack.indexversion configuration Shawn O. Pearce
2008-06-25 4:01 ` Shawn O. Pearce [this message]
2008-06-24 22:48 ` [JGIT PATCH 00/10] Support writing pack index version 2 Robin Rosenberg
2008-06-25 3:54 ` Shawn O. Pearce
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080625040148.GZ11793@spearce.org \
--to=spearce@spearce.org \
--cc=git@vger.kernel.org \
--cc=marek.zawirski@gmail.com \
--cc=robin.rosenberg@dewire.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.