Re: support for large packs and 64-bit offsets

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Linus Torvalds <torvalds@...>
Cc: Shawn O. Pearce <spearce@...>, Junio C Hamano <junkio@...>, <git@...>
Date: Monday, April 9, 2007 - 3:46 pm

On Mon, 9 Apr 2007, Nicolas Pitre wrote:


Something like this, although I suppose this might require a more 
permanent solution for the test suite:

diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index 8cf2871..8d20ea9 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -607,8 +607,12 @@ static void write_index_file(off_t last_obj_offset)
 	uint32_t array[256];
 	uint32_t index_version;
 
+#if 0
 	/* if last object's offset is >= 2^31 we should use index V2 */
 	index_version = (last_obj_offset >> 31) ? 2 : 1;
+#else
+	index_version = 2;
+#endif
 
 	/* index versions 2 and above need a header */
 	if (index_version >= 2) {
@@ -664,8 +668,15 @@ 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++;
+#if 0
 			uint32_t offset = (entry->offset <= 0x7fffffff) ?
 				entry->offset : (0x80000000 | nr_large_offset++);
+#else
+			/* force some offsets to the 64-bit table for testing */
+			uint32_t offset =
+				(!(entry->offset & 1) && entry->offset <= 0x7fffffff) ?
+				entry->offset : (0x80000000 | nr_large_offset++);
+#endif
 			offset = htonl(offset);
 			sha1write(f, &offset, 4);
 		}
@@ -675,7 +686,11 @@ 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 0
 			if (offset > 0x7fffffff) {
+#else
+			if (offset & 1 || offset > 0x7fffffff) {
+#endif
 				uint32_t split[2];
 				split[0]        = htonl(offset >> 32);
 				split[1] = htonl(offset & 0xffffffff);
diff --git a/index-pack.c b/index-pack.c
index a833f64..1e6db2b 100644
--- a/index-pack.c
+++ b/index-pack.c
@@ -718,8 +718,13 @@ static const char *write_index_file(const char *index_name, unsigned char *sha1)
 		die("unable to create %s: %s", index_name, strerror(errno));
 	f = sha1fd(fd, index_name);
 
+#if 0
 	/* if last object's offset is >= 2^31 we should use index V2 */
 	index_version = (objects[nr_objects-1].offset >> 31) ? 2 : 1;
+#else
+	/* force v2 always on for testing */
+	index_version = 2;
+#endif
 
 	/* index versions 2 and above need a header */
 	if (index_version >= 2) {
@@ -779,8 +784,15 @@ static const char *write_index_file(const char *index_name, unsigned char *sha1)
 		list = sorted_by_sha;
 		for (i = 0; i < nr_objects; i++) {
 			struct object_entry *obj = *list++;
+#if 0
 			uint32_t offset = (obj->offset <= 0x7fffffff) ?
 				obj->offset : (0x80000000 | nr_large_offset++);
+#else
+			/* force some offsets to the 64-bit table for testing */
+			uint32_t offset =
+				(!(obj->offset & 1) && obj->offset <= 0x7fffffff) ?
+				obj->offset : (0x80000000 | nr_large_offset++);
+#endif
 			offset = htonl(offset);
 			sha1write(f, &offset, 4);
 		}
@@ -790,7 +802,11 @@ static const char *write_index_file(const char *index_name, unsigned char *sha1)
 		while (nr_large_offset) {
 			struct object_entry *obj = *list++;
 			uint64_t offset = obj->offset;
+#if 0
 			if (offset > 0x7fffffff) {
+#else
+			if (offset & 1 || offset > 0x7fffffff) {
+#endif
 				uint32_t split[2];
 				split[0]	= htonl(offset >> 32);
 				split[1] = htonl(offset & 0xffffffff);
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
support for large packs and 64-bit offsets, Nicolas Pitre, (Mon Apr 9, 1:06 am)
Re: support for large packs and 64-bit offsets, Shawn O. Pearce, (Mon Apr 9, 1:19 pm)
Re: support for large packs and 64-bit offsets, Linus Torvalds, (Mon Apr 9, 2:02 pm)
Re: support for large packs and 64-bit offsets, Nicolas Pitre, (Mon Apr 9, 2:26 pm)
Re: support for large packs and 64-bit offsets, Nicolas Pitre, (Mon Apr 9, 3:46 pm)
Re: support for large packs and 64-bit offsets, Shawn O. Pearce, (Mon Apr 9, 2:34 pm)
Re: support for large packs and 64-bit offsets, Nicolas Pitre, (Mon Apr 9, 1:32 pm)
Re: support for large packs and 64-bit offsets, Shawn O. Pearce, (Mon Apr 9, 1:43 pm)
Re: support for large packs and 64-bit offsets, Junio C Hamano, (Mon Apr 9, 3:49 pm)
Re: support for large packs and 64-bit offsets, Shawn O. Pearce, (Mon Apr 9, 3:53 pm)
Re: support for large packs and 64-bit offsets, Junio C Hamano, (Mon Apr 9, 4:18 pm)
Re: support for large packs and 64-bit offsets, Nicolas Pitre, (Mon Apr 9, 4:02 pm)
[PATCH 01/10] get rid of num_packed_objects(), Nicolas Pitre, (Mon Apr 9, 1:06 am)
[PATCH 05/10] compute object CRC32 with index-pack, Nicolas Pitre, (Mon Apr 9, 1:06 am)