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

[PATCH v2 2/4] verify_packfile(): check as many object as possible in a pack

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Nov 7, 2011, 02:59 UTC
Message-ID
<1320634766-24511-3-git-send-email-pclouds@gmail.com>
In-Reply-To
<1320634766-24511-1-git-send-email-pclouds@gmail.com>

verify_packfile() checks for whole pack integerity first, then each object individually. Once we get past whole pack check, we can identify all objects in the pack. If there's an error with one object, we should continue to check the next objects to salvage as many objects as possible instead of stopping the process.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 pack-check.c |    9 ++-------
 1 files changed, 2 insertions(+), 7 deletions(-)
diff --git a/pack-check.c b/pack-check.c
index 0c19b6e..7ac9b3a 100644
--- a/pack-check.c
+++ b/pack-check.c
@@ -113,18 +113,13 @@ static int verify_packfile(struct packed_git *p,
 					    p->pack_name, (uintmax_t)offset);
 		}
 		data = unpack_entry(p, entries[i].offset, &type, &size);
-		if (!data) {
+		if (!data)
 			err = error("cannot unpack %s from %s at offset %"PRIuMAX"",
 				    sha1_to_hex(entries[i].sha1), p->pack_name,
 				    (uintmax_t)entries[i].offset);
-			break;
-		}
-		if (check_sha1_signature(entries[i].sha1, data, size, typename(type))) {
+		else if (check_sha1_signature(entries[i].sha1, data, size, typename(type)))
 			err = error("packed %s from %s is corrupt",
 				    sha1_to_hex(entries[i].sha1), p->pack_name);
-			free(data);
-			break;
-		}
 		free(data);
 	}
 	free(entries);
-- 
1.7.4.74.g639db
Previous: Nguyễn Thái Ngọc DuyNext: Nguyễn Thái Ngọc Duy
Message 3 of 6 in “fsck improvements”
  1. 0/4 fsck improvementsNguyễn Thái Ngọc Duy, Nov 7, 2011
  2. 1/4 fsck: return error code when verify_pack() goes wrongNguyễn Thái Ngọc Duy, Nov 7, 2011
  3. 2/4 verify_packfile(): check as many object as possible in a packNguyễn Thái Ngọc Duy, Nov 7, 2011
  4. 3/4 fsck: avoid reading every object twiceNguyễn Thái Ngọc Duy, Nov 7, 2011
  5. 4/4 fsck: print progressNguyễn Thái Ngọc Duy, Nov 7, 2011
  6. Junio C HamanoNov 7, 2011

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.