(CommandList
  children: [
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:test_description)
          op: Equal
          rhs: {(SQ <"see how we handle various forms of corruption">)}
          spids: [4]
        )
      ]
      spids: [4]
    )
    (C {(.)} {(./test-lib.sh)})
    (FuncDef
      name: obj_to_file
      body: 
        (BraceGroup
          children: [
            (C {(echo)} 
              {
                (DQ 
                  (CommandSubPart
                    command_list: (CommandList children:[(C {(git)} {(rev-parse)} {(--git-dir)})])
                    left_token: <Left_CommandSub "$(">
                    spids: [27 33]
                  ) (/objects/) 
                  (CommandSubPart
                    command_list: 
                      (CommandList
                        children: [
                          (Pipeline
                            children: [
                              (C {(git)} {(rev-parse)} {(DQ ($ VSub_Number "$1"))})
                              (C {(sed)} {(SQ <"s,..,&/,">)})
                            ]
                            negated: False
                          )
                        ]
                      )
                    left_token: <Left_CommandSub "$(">
                    spids: [35 51]
                  )
                )
              }
            )
          ]
          spids: [21]
        )
      spids: [17 20]
    )
    (FuncDef
      name: corrupt_byte
      body: 
        (BraceGroup
          children: [
            (AndOr
              children: [
                (Assignment
                  keyword: Assign_None
                  pairs: [
                    (assign_pair
                      lhs: (LhsName name:obj_file)
                      op: Equal
                      rhs: 
                        {
                          (CommandSubPart
                            command_list: 
                              (CommandList
                                children: [(C {(obj_to_file)} {(DQ ($ VSub_Number "$1"))})]
                              )
                            left_token: <Left_CommandSub "$(">
                            spids: [68 74]
                          )
                        }
                      spids: [67]
                    )
                  ]
                  spids: [67]
                )
                (AndOr
                  children: [
                    (C {(chmod)} {(Lit_Other "+") (w)} {(DQ ($ VSub_Name "$obj_file"))})
                    (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: False
                    )
                  ]
                  op_id: Op_DAmp
                )
              ]
              op_id: Op_DAmp
            )
          ]
          spids: [64]
        )
      spids: [60 63]
    )
    (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)})
  ]
)