git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 0/11] Misc. pull/merge/am improvements

From
Junio C Hamano <junkio@cox.net>
Date
Dec 29, 2006, 06:14 UTC
Message-ID
<7vmz57p6tn.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20061229045327.GD12072@spearce.org>
Shawn Pearce <spearce@spearce.org> writes:
Show 10 quoted lines
> Junio C Hamano <junkio@cox.net> wrote:
>> While I was looking at the problem, I noticed something a bit
>> easier to reproduce and should be lot easier to diagnose.  At
>> http://userweb.kernel.org/~junio/broken.tar, I have a tarball of
>> git.git repository.
>
> Thanks.  I downloaded that tar but I can't debug it right now.
> I'm feeling under the weather and already had a long day; I'm too
> fried to seriously look at this pack code.  I'll do it tomorrow
> evening.

I think there is a thinko in the OFS_DELTA arm of that switch statement. You are resetting buf to (in-pack-offset + used), so you should fetch the variably encoded length starting from buf[0].

This seems to fix that particular repacking for me.
---
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index e9a1804..42dd8c8 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -1003,6 +1003,7 @@ static void check_object(struct object_entry *entry)
 		if (!no_reuse_delta) {
 			unsigned char c, *base_name;
 			unsigned long ofs;
+			unsigned long used_0;
 			/* there is at least 20 bytes left in the pack */
 			switch (entry->in_pack_type) {
 			case OBJ_REF_DELTA:
@@ -1013,14 +1014,15 @@ static void check_object(struct object_entry *entry)
 			case OBJ_OFS_DELTA:
 				buf = use_pack(p, &w_curs,
 					entry->in_pack_offset + used, NULL);
-				c = buf[used++];
+				used_0 = 0;
+				c = buf[used_0++];
 				ofs = c & 127;
 				while (c & 128) {
 					ofs += 1;
 					if (!ofs || ofs & ~(~0UL >> 7))
 						die("delta base offset overflow in pack for %s",
 						    sha1_to_hex(entry->sha1));
-					c = buf[used++];
+					c = buf[used_0++];
 					ofs = (ofs << 7) + (c & 127);
 				}
 				if (ofs >= entry->in_pack_offset)
@@ -1028,6 +1030,7 @@ static void check_object(struct object_entry *entry)
 					    sha1_to_hex(entry->sha1));
 				ofs = entry->in_pack_offset - ofs;
 				base_name = find_packed_object_name(p, ofs);
+				used += used_0;
 				break;
 			default:
 				base_name = NULL;
Previous: Shawn PearceNext: Shawn Pearce
Message 6 of 10 in “Misc. pull/merge/am improvements”
  1. 0/11 Misc. pull/merge/am improvementsShawn Pearce, Dec 28, 2006
  2. Junio C HamanoDec 28, 2006
  3. Shawn PearceDec 28, 2006
  4. Junio C HamanoDec 28, 2006
  5. Shawn PearceDec 29, 2006
  6. Junio C HamanoDec 29, 2006
  7. Shawn PearceDec 31, 2006
  8. Junio C HamanoDec 30, 2006
  9. Johannes SchindelinDec 29, 2006
  10. Junio C HamanoDec 29, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.