diff options
author | Nicolas Pitre <nico@cam.org> | 2007-04-09 17:32:03 -0400 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2007-04-10 12:48:14 -0700 |
commit | 4ba7d711539122c21bd44af06b6cab4fc4f65a74 (patch) | |
tree | c3a073216a0007c1461bcd9f433efe0386c80290 /builtin-pack-objects.c | |
parent | 8c681e07c91b544756e2631493ebc15abd1e8589 (diff) | |
download | git-4ba7d711539122c21bd44af06b6cab4fc4f65a74.tar.gz |
allow forcing index v2 and 64-bit offset treshold
This is necessary for testing the new capabilities in some automated
way without having an actual 4GB+ pack.
Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'builtin-pack-objects.c')
-rw-r--r-- | builtin-pack-objects.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c index 8cf2871751..099dea0e1e 100644 --- a/builtin-pack-objects.c +++ b/builtin-pack-objects.c @@ -597,6 +597,9 @@ static off_t write_pack_file(void) return last_obj_offset; } +static uint32_t index_default_version = 1; +static uint32_t index_off32_limit = 0x7fffffff; + static void write_index_file(off_t last_obj_offset) { uint32_t i; @@ -608,7 +611,7 @@ static void write_index_file(off_t last_obj_offset) uint32_t index_version; /* if last object's offset is >= 2^31 we should use index V2 */ - index_version = (last_obj_offset >> 31) ? 2 : 1; + index_version = (last_obj_offset >> 31) ? 2 : index_default_version; /* index versions 2 and above need a header */ if (index_version >= 2) { @@ -664,7 +667,7 @@ static void write_index_file(off_t last_obj_offset) list = sorted_by_sha; for (i = 0; i < nr_objects; i++) { struct object_entry *entry = *list++; - uint32_t offset = (entry->offset <= 0x7fffffff) ? + uint32_t offset = (entry->offset <= index_off32_limit) ? entry->offset : (0x80000000 | nr_large_offset++); offset = htonl(offset); sha1write(f, &offset, 4); @@ -675,7 +678,7 @@ static void write_index_file(off_t last_obj_offset) while (nr_large_offset) { struct object_entry *entry = *list++; uint64_t offset = entry->offset; - if (offset > 0x7fffffff) { + if (offset > index_off32_limit) { uint32_t split[2]; split[0] = htonl(offset >> 32); split[1] = htonl(offset & 0xffffffff); @@ -1714,6 +1717,17 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) rp_av[1] = "--objects-edge"; continue; } + if (!prefixcmp(arg, "--index-version=")) { + char *c; + index_default_version = strtoul(arg + 16, &c, 10); + if (index_default_version > 2) + die("bad %s", arg); + if (*c == ',') + index_off32_limit = strtoul(c+1, &c, 0); + if (*c || index_off32_limit & 0x80000000) + die("bad %s", arg); + continue; + } usage(pack_usage); } |