3 test_description='see how we handle various forms of corruption'
6 # convert "1234abcd" to ".git/objects/12/34abcd"
8 echo "$(git rev-parse --git-dir)/objects/$(git rev-parse "$1" | sed 's,..,&/,')"
11 # Convert byte at offset "$2" of object "$1" into '\0'
13 obj_file=$(obj_to_file "$1") &&
14 chmod +w "$obj_file" &&
15 printf '\0' | dd of="$obj_file" bs=1 seek="$2" conv=notrunc
18 test_expect_success 'setup corrupt repo' '
22 test_commit content &&
23 corrupt_byte HEAD:content.t 10
27 test_expect_success 'setup repo with missing object' '
31 test_commit content &&
32 rm -f "$(obj_to_file HEAD:content.t)"
36 test_expect_success 'streaming a corrupt blob fails' '
39 test_must_fail git cat-file blob HEAD:content.t
43 test_expect_success 'read-tree -u detects bit-errors in blobs' '
47 test_must_fail git read-tree --reset -u HEAD
51 test_expect_success 'read-tree -u detects missing objects' '
55 test_must_fail git read-tree --reset -u HEAD