Merge branch 'jk/unpack-entry-fallback-to-another'

* jk/unpack-entry-fallback-to-another:
  unpack_entry: do not die when we fail to apply a delta
  t5303: drop "count=1" from corruption dd
This commit is contained in:
Junio C Hamano 2013-06-23 14:53:20 -07:00
commit ee64e345b1
2 changed files with 38 additions and 2 deletions

View File

@ -2145,8 +2145,17 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,
data = patch_delta(base, base_size,
delta_data, delta_size,
&size);
/*
* We could not apply the delta; warn the user, but keep going.
* Our failure will be noticed either in the next iteration of
* the loop, or if this is the final delta, in the caller when
* we return NULL. Those code paths will take care of making
* a more explicit warning and retrying with another copy of
* the object.
*/
if (!data)
die("failed to apply delta");
error("failed to apply delta");
free(delta_data);
}

View File

@ -51,7 +51,7 @@ do_corrupt_object() {
ofs=`git show-index < ${pack}.idx | grep $1 | cut -f1 -d" "` &&
ofs=$(($ofs + $2)) &&
chmod +w ${pack}.pack &&
dd of=${pack}.pack count=1 bs=1 conv=notrunc seek=$ofs &&
dd of=${pack}.pack bs=1 conv=notrunc seek=$ofs &&
test_must_fail git verify-pack ${pack}.pack
}
@ -275,6 +275,33 @@ test_expect_success \
git cat-file blob $blob_2 > /dev/null &&
git cat-file blob $blob_3 > /dev/null'
test_expect_success \
'corruption of delta base reference pointing to wrong object' \
'create_new_pack --delta-base-offset &&
git prune-packed &&
printf "\220\033" | do_corrupt_object $blob_3 2 &&
git cat-file blob $blob_1 >/dev/null &&
git cat-file blob $blob_2 >/dev/null &&
test_must_fail git cat-file blob $blob_3 >/dev/null'
test_expect_success \
'... but having a loose copy allows for full recovery' \
'mv ${pack}.idx tmp &&
git hash-object -t blob -w file_3 &&
mv tmp ${pack}.idx &&
git cat-file blob $blob_1 > /dev/null &&
git cat-file blob $blob_2 > /dev/null &&
git cat-file blob $blob_3 > /dev/null'
test_expect_success \
'... and then a repack "clears" the corruption' \
'do_repack --delta-base-offset --no-reuse-delta &&
git prune-packed &&
git verify-pack ${pack}.pack &&
git cat-file blob $blob_1 > /dev/null &&
git cat-file blob $blob_2 > /dev/null &&
git cat-file blob $blob_3 > /dev/null'
test_expect_success \
'corrupting header to have too small output buffer fails unpack' \
'create_new_pack &&