Merge branch 'jk/loose-object-info-report-error'
Update error handling for codepath that deals with corrupt loose objects. * jk/loose-object-info-report-error: index-pack: detect local corruption in collision check sha1_loose_object_info: return error for corrupted objects
This commit is contained in:
commit
dfe46c5ce6
@ -810,6 +810,8 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
|
||||
unsigned long has_size;
|
||||
read_lock();
|
||||
has_type = sha1_object_info(sha1, &has_size);
|
||||
if (has_type < 0)
|
||||
die(_("cannot read existing object info %s"), sha1_to_hex(sha1));
|
||||
if (has_type != type || has_size != size)
|
||||
die(_("SHA1 COLLISION FOUND WITH %s !"), sha1_to_hex(sha1));
|
||||
has_data = read_sha1_file(sha1, &has_type, &has_size);
|
||||
|
@ -2952,7 +2952,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)
|
||||
|
@ -21,6 +21,14 @@ test_expect_success 'setup corrupt repo' '
|
||||
cd bit-error &&
|
||||
test_commit content &&
|
||||
corrupt_byte HEAD:content.t 10
|
||||
) &&
|
||||
git init no-bit-error &&
|
||||
(
|
||||
# distinct commit from bit-error, but containing a
|
||||
# non-corrupted version of the same blob
|
||||
cd no-bit-error &&
|
||||
test_tick &&
|
||||
test_commit content
|
||||
)
|
||||
'
|
||||
|
||||
@ -53,6 +61,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 &&
|
||||
@ -101,4 +116,13 @@ test_expect_failure 'clone --local detects misnamed objects' '
|
||||
test_must_fail git clone --local misnamed misnamed-checkout
|
||||
'
|
||||
|
||||
test_expect_success 'fetch into corrupted repo with index-pack' '
|
||||
(
|
||||
cd bit-error &&
|
||||
test_must_fail git -c transfer.unpackLimit=1 \
|
||||
fetch ../no-bit-error 2>stderr &&
|
||||
test_i18ngrep ! -i collision stderr
|
||||
)
|
||||
'
|
||||
|
||||
test_done
|
||||
|
Loading…
Reference in New Issue
Block a user