diff options
-rw-r--r-- | sha1_file.c | 2 | ||||
-rwxr-xr-x | t/t1060-object-corruption.sh | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/sha1_file.c b/sha1_file.c index d77b915db6..b8fbcc54c5 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -2867,7 +2867,7 @@ static int sha1_loose_object_info(const unsigned char *sha1, if (status && oi->typep) *oi->typep = status; strbuf_release(&hdrbuf); - return 0; + return (status < 0) ? status : 0; } int sha1_object_info_extended(const unsigned char *sha1, struct object_info *oi, unsigned flags) diff --git a/t/t1060-object-corruption.sh b/t/t1060-object-corruption.sh index 3f8705139d..3a88d79c5f 100755 --- a/t/t1060-object-corruption.sh +++ b/t/t1060-object-corruption.sh @@ -53,6 +53,13 @@ test_expect_success 'streaming a corrupt blob fails' ' ) ' +test_expect_success 'getting type of a corrupt blob fails' ' + ( + cd bit-error && + test_must_fail git cat-file -s HEAD:content.t + ) +' + test_expect_success 'read-tree -u detects bit-errors in blobs' ' ( cd bit-error && |