|
3 | 3 | test_description='see how we handle various forms of corruption'
|
4 | 4 |
|
5 | 5 | . ./test-lib.sh
|
| 6 | +. "$TEST_DIRECTORY"/lib-diff-data.sh |
6 | 7 |
|
7 | 8 | # convert "1234abcd" to ".git/objects/12/34abcd"
|
8 | 9 | obj_to_file() {
|
@@ -62,6 +63,35 @@ test_expect_success 'streaming a corrupt blob fails' '
|
62 | 63 | )
|
63 | 64 | '
|
64 | 65 |
|
| 66 | +test_expect_success PERL 'truncated objects can be re-retrieved via GVFS' ' |
| 67 | + git init truncated && |
| 68 | + COPYING_test_data >truncated/COPYING && |
| 69 | + git -C truncated add COPYING && |
| 70 | + test_tick && |
| 71 | + git -C truncated commit -m initial COPYING && |
| 72 | +
|
| 73 | + # set up the `read-object` hook so that it overwrites the corrupt object |
| 74 | + mkdir -p truncated/.git/hooks && |
| 75 | + sed -e "1s|/usr/bin/perl|$PERL_PATH|" \ |
| 76 | + -e "s/system/unlink \".git\/objects\/\" . substr(\$sha1, 0, 2) . \"\/\" . substr(\$sha1, 2); &/" \ |
| 77 | + <$TEST_DIRECTORY/t0410/read-object \ |
| 78 | + >truncated/.git/hooks/read-object && |
| 79 | + chmod +x truncated/.git/hooks/read-object && |
| 80 | +
|
| 81 | + # ensure that the parent repository has a copy of the object, from |
| 82 | + # where the `read-object` can read it |
| 83 | + sha="$(git hash-object -w truncated/COPYING)" && |
| 84 | + file=$(obj_to_file $sha) && |
| 85 | + size=$(test_file_size $file) && |
| 86 | + chmod u+w truncated/$file && |
| 87 | + test-tool truncate truncated/$file $(($size-8)) && |
| 88 | +
|
| 89 | + rm truncated/COPYING && |
| 90 | + test_must_fail git -C truncated reset --hard && |
| 91 | + git -C truncated -c core.gvfs=4 -c core.virtualizeObjects \ |
| 92 | + reset --hard |
| 93 | +' |
| 94 | + |
65 | 95 | test_expect_success 'getting type of a corrupt blob fails' '
|
66 | 96 | (
|
67 | 97 | cd bit-error &&
|
|
0 commit comments