Re: heads-up: git-index-pack in "next" is broken

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Nicolas Pitre
Date: Tuesday, October 17, 2006 - 1:23 pm

On Tue, 17 Oct 2006, Sergey Vlasov wrote:


Ah bummer.  Then this is most likely the cause.  And here's a simple 
fix (Junio please confirm):

diff --git a/index-pack.c b/index-pack.c
index fffddd2..56c590e 100644
--- a/index-pack.c
+++ b/index-pack.c
@@ -23,6 +23,12 @@ union delta_base {
 	unsigned long offset;
 };
 
+/*
+ * Even if sizeof(union delta_base) == 24 on 64-bit archs, we really want
+ * to memcmp() only the first 20 bytes.
+ */
+#define UNION_BASE_SZ	20
+
 struct delta_entry
 {
 	struct object_entry *obj;
@@ -211,7 +217,7 @@ static int find_delta(const union delta_
                 struct delta_entry *delta = &deltas[next];
                 int cmp;
 
-                cmp = memcmp(base, &delta->base, sizeof(*base));
+                cmp = memcmp(base, &delta->base, UNION_BASE_SZ);
                 if (!cmp)
                         return next;
                 if (cmp < 0) {
@@ -232,9 +238,9 @@ static int find_delta_childs(const union
 
 	if (first < 0)
 		return -1;
-	while (first > 0 && !memcmp(&deltas[first - 1].base, base, sizeof(*base)))
+	while (first > 0 && !memcmp(&deltas[first - 1].base, base, UNION_BASE_SZ))
 		--first;
-	while (last < end && !memcmp(&deltas[last + 1].base, base, sizeof(*base)))
+	while (last < end && !memcmp(&deltas[last + 1].base, base, UNION_BASE_SZ))
 		++last;
 	*first_index = first;
 	*last_index = last;
@@ -312,7 +318,7 @@ static int compare_delta_entry(const voi
 {
 	const struct delta_entry *delta_a = a;
 	const struct delta_entry *delta_b = b;
-	return memcmp(&delta_a->base, &delta_b->base, sizeof(union delta_base));
+	return memcmp(&delta_a->base, &delta_b->base, UNION_BASE_SZ);
 }
 
 static void parse_pack_objects(void)


Nicolas
-
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:
heads-up: git-index-pack in &quot;next&quot; is broken, Junio C Hamano, (Mon Oct 16, 9:55 pm)
Re: heads-up: git-index-pack in &quot;next&quot; is broken, Junio C Hamano, (Tue Oct 17, 9:07 am)
Re: heads-up: git-index-pack in &quot;next&quot; is broken, Nicolas Pitre, (Tue Oct 17, 10:00 am)
Re: heads-up: git-index-pack in &quot;next&quot; is broken, Junio C Hamano, (Tue Oct 17, 11:11 am)
Re: heads-up: git-index-pack in &quot;next&quot; is broken, Nicolas Pitre, (Tue Oct 17, 11:47 am)
Re: heads-up: git-index-pack in &quot;next&quot; is broken, Sergey Vlasov, (Tue Oct 17, 12:36 pm)
Re: heads-up: git-index-pack in &quot;next&quot; is broken, Junio C Hamano, (Tue Oct 17, 1:10 pm)
Re: heads-up: git-index-pack in "next" is broken, Nicolas Pitre, (Tue Oct 17, 1:23 pm)
Re: heads-up: git-index-pack in &quot;next&quot; is broken, Linus Torvalds, (Tue Oct 17, 1:51 pm)
Re: heads-up: git-index-pack in &quot;next&quot; is broken, Linus Torvalds, (Tue Oct 17, 2:46 pm)
Re: heads-up: git-index-pack in &quot;next&quot; is broken, Junio C Hamano, (Tue Oct 17, 2:54 pm)
Re: heads-up: git-index-pack in &quot;next&quot; is broken, Linus Torvalds, (Tue Oct 17, 5:57 pm)
Re: heads-up: git-index-pack in &quot;next&quot; is broken, Junio C Hamano, (Tue Oct 17, 6:30 pm)
Re: heads-up: git-index-pack in &quot;next&quot; is broken, Linus Torvalds, (Tue Oct 17, 8:12 pm)
Re: heads-up: git-index-pack in &quot;next&quot; is broken, Junio C Hamano, (Tue Oct 17, 9:16 pm)
Re: heads-up: git-index-pack in &quot;next&quot; is broken, Junio C Hamano, (Tue Oct 17, 10:07 pm)
Re: heads-up: git-index-pack in &quot;next&quot; is broken, Davide Libenzi, (Tue Oct 17, 11:09 pm)
Re: heads-up: git-index-pack in &quot;next&quot; is broken, Johannes Schindelin, (Wed Oct 18, 3:00 am)
Re: heads-up: git-index-pack in &quot;next&quot; is broken, Linus Torvalds, (Wed Oct 18, 7:56 am)
Re: heads-up: git-index-pack in &quot;next&quot; is broken, Davide Libenzi, (Wed Oct 18, 9:17 am)
Re: heads-up: git-index-pack in &quot;next&quot; is broken, Linus Torvalds, (Wed Oct 18, 9:52 am)
Re: heads-up: git-index-pack in &quot;next&quot; is broken, Davide Libenzi, (Wed Oct 18, 2:21 pm)
Re: heads-up: git-index-pack in &quot;next&quot; is broken, Linus Torvalds, (Wed Oct 18, 2:48 pm)
Re: heads-up: git-index-pack in &quot;next&quot; is broken, Davide Libenzi, (Wed Oct 18, 3:34 pm)