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

[PATCH] make pack-objects a bit more resilient to repo corruption

From
Nicolas Pitre <nico@fluxnic.net>
Date
Oct 22, 2010, 04:53 UTC
Message-ID
<alpine.LFD.2.00.1010220037250.2764@xanadu.home>

Right now, packing valid objects could fail when creating a thin pack simply because a pack edge object used as a preferred base is corrupted. Since preferred base objects are not strictly needed to produce a valid pack, let's not consider the inability to read them as a fatal error. Delta compression may well be attempted against other objects in the search window.

Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
---

I wrote this patch while helping Uwe with his repo corruption. While his problem turned out to be different from the one this patch is addressing (see previous patch I posted) I think that since I did the patch already then this wouldn't hurt to have this one merged too.

diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index f8eba53..674247e 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -1298,9 +1298,19 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
 		read_lock();
 		src->data = read_sha1_file(src_entry->idx.sha1, &type, &sz);
 		read_unlock();
-		if (!src->data)
+		if (!src->data) {
+			if (src_entry->preferred_base) {
+				/* 
+				 * Those objects are not included in the
+				 * resulting pack.  Be resilient and ignore
+				 * them if they can't be read, in case the
+				 * pack could be created nevertheless.
+				 */
+				return 0;
+			}
 			die("object %s cannot be read",
 			    sha1_to_hex(src_entry->idx.sha1));
+		}
 		if (sz != src_size)
 			die("object %s inconsistent object length (%lu vs %lu)",
 			    sha1_to_hex(src_entry->idx.sha1), sz, src_size);
Next: Jeff King
Message 1 of 11 in “make pack-objects a bit more resilient to repo corruption”
  1. make pack-objects a bit more resilient to repo corruptionNicolas Pitre, Oct 22, 2010
  2. Jeff KingOct 22, 2010
  3. Drew NorthupOct 22, 2010
  4. Nicolas PitreOct 22, 2010
  5. Nicolas PitreOct 22, 2010
  6. make pack-objects a bit more resilient to repo corruptionNicolas Pitre, Oct 22, 2010
  7. Sverre RabbelierOct 22, 2010
  8. Nicolas PitreOct 22, 2010
  9. Junio C HamanoOct 22, 2010
  10. Geert BoschOct 24, 2010
  11. Nicolas PitreOct 24, 2010

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.