Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>2010-06-10 16:47:01 +0400
committerJunio C Hamano <gitster@pobox.com>2010-07-15 02:35:12 +0400
commite8b15e6156fc361d3cb0e093747dab840d58fc7e (patch)
treeabe35e3b729a5a7046ad481635be467f528f0b90 /sha1_file.c
parentfc051572a3fe171286f10761bd33946c48de3f7f (diff)
sha1_file: Show the the type and path to corrupt objects
Change the error message that's displayed when we encounter corrupt objects to be more specific. We now print the type (loose or packed) of corrupted objects, along with the full path to the file in question. Before: $ git cat-file blob 909ef997367880aaf2133bafa1f1a71aa28e09df fatal: object 909ef997367880aaf2133bafa1f1a71aa28e09df is corrupted After: $ git cat-file blob 909ef997367880aaf2133bafa1f1a71aa28e09df fatal: loose object 909ef997367880aaf2133bafa1f1a71aa28e09df (stored in .git/objects/90/9ef997367880aaf2133bafa1f1a71aa28e09df) is corrupted Knowing the path helps to quickly analyze what's wrong: $ file .git/objects/90/9ef997367880aaf2133bafa1f1a71aa28e09df .git/objects/90/9ef997367880aaf2133bafa1f1a71aa28e09df: empty Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/sha1_file.c b/sha1_file.c
index e42ef96d45..0cd9435619 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -2086,6 +2086,7 @@ 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)
@@ -2093,8 +2094,16 @@ void *read_sha1_file_repl(const unsigned char *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;