(command.CommandList children: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:test_description spids:[12]) op: Equal rhs: {(SQ <'see how we handle various forms of corruption'>)} spids: [12] ) ] spids: [12] ) (C {(.)} {(./test-lib.sh)}) (command.FuncDef name: obj_to_file body: (command.BraceGroup children: [ (C {(echo)} { (DQ (word_part.CommandSubPart command_list: (command.CommandList children: [(C {(git)} {(rev-parse)} {(--git-dir)})] ) left_token: <Left_CommandSub '$('> spids: [35 41] ) (/objects/) (word_part.CommandSubPart command_list: (command.CommandList children: [ (command.Pipeline children: [ (C {(git)} {(rev-parse)} {(DQ ($ VSub_Number '$1'))}) (C {(sed)} {(SQ <'s,..,&/,'>)}) ] negated: F ) ] ) left_token: <Left_CommandSub '$('> spids: [43 59] ) ) } ) ] spids: [29] ) spids: [25 28] ) (command.FuncDef name: corrupt_byte body: (command.BraceGroup children: [ (command.AndOr ops: [Op_DAmp Op_DAmp] children: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:obj_file spids:[75]) op: Equal rhs: { (word_part.CommandSubPart command_list: (command.CommandList children: [(C {(obj_to_file)} {(DQ ($ VSub_Number '$1'))})] ) left_token: <Left_CommandSub '$('> spids: [76 82] ) } spids: [75] ) ] spids: [75] ) (C {(chmod)} {(Lit_Other '+') (w)} {(DQ ($ VSub_Name '$obj_file'))}) (command.Pipeline children: [ (C {(printf)} {(SQ <'\\0'>)}) (C {(dd)} {(Lit_VarLike 'of=') (DQ ($ VSub_Name '$obj_file'))} {(Lit_VarLike 'bs=') (1)} {(Lit_VarLike 'seek=') (DQ ($ VSub_Number '$2'))} {(Lit_VarLike 'conv=') (notrunc)} ) ] negated: F ) ] ) ] spids: [72] ) spids: [68 71] ) (C {(test_expect_success)} {(SQ <'setup corrupt repo'>)} { (SQ <'\n'> <'\tgit init bit-error &&\n'> <'\t(\n'> <'\t\tcd bit-error &&\n'> <'\t\ttest_commit content &&\n'> <'\t\tcorrupt_byte HEAD:content.t 10\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'setup repo with missing object'>)} { (SQ <'\n'> <'\tgit init missing &&\n'> <'\t(\n'> <'\t\tcd missing &&\n'> <'\t\ttest_commit content &&\n'> <'\t\trm -f "$(obj_to_file HEAD:content.t)"\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'setup repo with misnamed object'>)} { (SQ <'\n'> <'\tgit init misnamed &&\n'> <'\t(\n'> <'\t\tcd misnamed &&\n'> <'\t\ttest_commit content &&\n'> <'\t\tgood=$(obj_to_file HEAD:content.t) &&\n'> <'\t\tblob=$(echo corrupt | git hash-object -w --stdin) &&\n'> <'\t\tbad=$(obj_to_file $blob) &&\n'> <'\t\trm -f "$good" &&\n'> <'\t\tmv "$bad" "$good"\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'streaming a corrupt blob fails'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd bit-error &&\n'> <'\t\ttest_must_fail git cat-file blob HEAD:content.t\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'read-tree -u detects bit-errors in blobs'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd bit-error &&\n'> <'\t\trm -f content.t &&\n'> <'\t\ttest_must_fail git read-tree --reset -u HEAD\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'read-tree -u detects missing objects'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd missing &&\n'> <'\t\trm -f content.t &&\n'> <'\t\ttest_must_fail git read-tree --reset -u HEAD\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'clone --no-local --bare detects corruption'>)} {(SQ <'\n'> <'\ttest_must_fail git clone --no-local --bare bit-error corrupt-transport\n'>)} ) (C {(test_expect_success)} {(SQ <'clone --no-local --bare detects missing object'>)} {(SQ <'\n'> <'\ttest_must_fail git clone --no-local --bare missing missing-transport\n'>)} ) (C {(test_expect_success)} {(SQ <'clone --no-local --bare detects misnamed object'>)} {(SQ <'\n'> <'\ttest_must_fail git clone --no-local --bare misnamed misnamed-transport\n'>)} ) (C {(test_expect_success)} {(SQ <'clone --local detects corruption'>)} {(SQ <'\n'> <'\ttest_must_fail git clone --local bit-error corrupt-checkout\n'>)} ) (C {(test_expect_success)} {(SQ <'error detected during checkout leaves repo intact'>)} {(SQ <'\n'> <'\ttest_path_is_dir corrupt-checkout/.git\n'>)} ) (C {(test_expect_success)} {(SQ <'clone --local detects missing objects'>)} {(SQ <'\n'> <'\ttest_must_fail git clone --local missing missing-checkout\n'>)} ) (C {(test_expect_failure)} {(SQ <'clone --local detects misnamed objects'>)} {(SQ <'\n'> <'\ttest_must_fail git clone --local misnamed misnamed-checkout\n'>)} ) (C {(test_done)}) ] )