author | Junio C Hamano <gitster@pobox.com> | |
Wed, 18 Aug 2010 19:16:41 +0000 (12:16 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 18 Aug 2010 19:16:41 +0000 (12:16 -0700) |
* ab/report-corrupt-object-with-type:
sha1_file: Show the the type and path to corrupt objects
sha1_file: Show the the type and path to corrupt objects
sha1_file.c | patch | blob | history |
diff --git a/sha1_file.c b/sha1_file.c
index e42ef96d457f6aa12ab7d0057acf936db0335d40..0cd9435619f1e0637584289b45d52c1cdd8a9460 100644 (file)
--- a/sha1_file.c
+++ b/sha1_file.c
{
const unsigned char *repl = lookup_replace_object(sha1);
void *data = read_object(repl, type, size);
+ char *path;
/* die if we replaced an object with one that does not exist */
if (!data && repl != sha1)
sha1_to_hex(repl), sha1_to_hex(sha1));
/* legacy behavior is to die on corrupted objects */
- if (!data && (has_loose_object(repl) || has_packed_and_bad(repl)))
- die("object %s is corrupted", sha1_to_hex(repl));
+ if (!data) {
+ if (has_loose_object(repl)) {
+ path = sha1_file_name(sha1);
+ die("loose object %s (stored in %s) is corrupted", sha1_to_hex(repl), path);
+ }
+ if (has_packed_and_bad(repl)) {
+ path = sha1_pack_name(sha1);
+ die("packed object %s (stored in %s) is corrupted", sha1_to_hex(repl), path);
+ }
+ }
if (replacement)
*replacement = repl;