Skip to content

Commit

Permalink
Merge branch 'ab/report-corrupt-object-with-type'
Browse files Browse the repository at this point in the history
* ab/report-corrupt-object-with-type:
  sha1_file: Show the the type and path to corrupt objects
  • Loading branch information
Junio C Hamano committed Aug 18, 2010
2 parents 9c74b94 + e8b15e6 commit cdcf08e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions sha1_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -2086,15 +2086,24 @@ void *read_sha1_file_repl(const unsigned char *sha1,
{
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)
die("replacement %s not found for %s",
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;
Expand Down

0 comments on commit cdcf08e

Please sign in to comment.