(CommandList
  children: [
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:test_description)
          op: Equal
          rhs: {(SQ <'test corner cases of git-archive'>)}
          spids: [4]
        )
      ]
      spids: [4]
    )
    (C {(.)} {(./test-lib.sh)})
    (C {(test_expect_success)} {(SQ <'create commit with empty tree'>)} 
      {(SQ <'\n'> <'\tgit commit --allow-empty -m foo\n'>)}
    )
    (FuncDef
      name: make_dir
      body: 
        (BraceGroup
          children: [
            (AndOr
              children: [
                (C {(mkdir)} {(DQ ($ VSub_Number '$1'))})
                (C {(test_when_finished)} {(DQ ("rm -rf '") ($ VSub_Number '$1') ("'"))})
              ]
              op_id: Op_DAmp
            )
          ]
          spids: [33]
        )
      spids: [29 32]
    )
    (FuncDef
      name: check_dir
      body: 
        (BraceGroup
          children: [
            (Sentence
              child: 
                (Assignment
                  keyword: Assign_None
                  pairs: [
                    (assign_pair
                      lhs: (LhsName name:dir)
                      op: Equal
                      rhs: {($ VSub_Number '$1')}
                      spids: [69]
                    )
                  ]
                  spids: [69]
                )
              terminator: <Op_Semi ';'>
            )
            (C {(shift)})
            (AndOr
              children: [
                (Pipeline
                  children: [
                    (BraceGroup
                      children: [
                        (AndOr
                          children: [
                            (C {(echo)} {(DQ ($ VSub_Name '$dir'))})
                            (ForEach
                              iter_name: i
                              iter_words: [{(DQ ($ VSub_At '$@'))}]
                              do_arg_iter: False
                              body: 
                                (DoGroup
                                  children: [
                                    (C {(echo)} {(DQ ($ VSub_Name '$dir') (/) ($ VSub_Name '$i'))})
                                  ]
                                  spids: [99 111]
                                )
                              spids: [93 97]
                            )
                          ]
                          op_id: Op_DAmp
                        )
                      ]
                      spids: [76]
                    )
                    (SimpleCommand
                      words: [{(sort)}]
                      redirects: [
                        (Redir
                          op_id: Redir_Great
                          fd: 16777215
                          arg_word: {(expect)}
                          spids: [120]
                        )
                      ]
                    )
                  ]
                  negated: False
                )
                (AndOr
                  children: [
                    (Pipeline
                      children: [
                        (C {(find)} {(DQ ($ VSub_Name '$dir'))} {(KW_Bang '!')} {(-name)} 
                          {(pax_global_header)} {(-print)}
                        )
                        (SimpleCommand
                          words: [{(sort)}]
                          redirects: [
                            (Redir
                              op_id: Redir_Great
                              fd: 16777215
                              arg_word: {(actual)}
                              spids: [144]
                            )
                          ]
                        )
                      ]
                      negated: False
                    )
                    (C {(test_cmp)} {(expect)} {(actual)})
                  ]
                  op_id: Op_DAmp
                )
              ]
              op_id: Op_DAmp
            )
          ]
          spids: [66]
        )
      spids: [62 65]
    )
    (If
      arms: [
        (if_arm
          cond: [
            (SimpleCommand
              words: [
                {(DQ ($ VSub_Name '$TAR'))}
                {(tf)}
                {(DQ ($ VSub_Name '$TEST_DIRECTORY')) (/t5004/empty-with-pax-header.tar)}
              ]
              redirects: [
                (Redir
                  op_id: Redir_Great
                  fd: 16777215
                  arg_word: {(/dev/null)}
                  spids: [179]
                )
                (Redir op_id:Redir_GreatAnd fd:2 arg_word:{(1)} spids:[182])
              ]
            )
          ]
          action: [(C {(test_set_prereq)} {(HEADER_ONLY_TAR_OK)})]
          spids: [16777215 185]
        )
      ]
      spids: [16777215 192]
    )
    (C {(test_expect_success)} {(HEADER_ONLY_TAR_OK)} {(SQ <'tar archive of commit with empty tree'>)} 
      {
        (SQ <'\n'> <'\tgit archive --format=tar HEAD >empty-with-pax-header.tar &&\n'> 
          <'\tmake_dir extract &&\n'> <'\t"$TAR" xf empty-with-pax-header.tar -C extract &&\n'> <'\tcheck_dir extract\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'tar archive of empty tree is empty'>)} 
      {
        (SQ <'\n'> <'\tgit archive --format=tar HEAD: >empty.tar &&\n'> 
          <'\tperl -e "print \\"\\\\0\\" x 10240" >10knuls.tar &&\n'> <'\ttest_cmp_bin 10knuls.tar empty.tar\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'tar archive of empty tree with prefix'>)} 
      {
        (SQ <'\n'> <'\tgit archive --format=tar --prefix=foo/ HEAD >prefix.tar &&\n'> 
          <'\tmake_dir extract &&\n'> <'\t"$TAR" xf prefix.tar -C extract &&\n'> <'\tcheck_dir extract foo\n'>
        )
      }
    )
    (C {(test_expect_success)} {(UNZIP)} {(SQ <'zip archive of empty tree is empty'>)} 
      {
        (SQ <'\n'> <'\t# Detect the exit code produced when our particular flavor of unzip\n'> 
          <'\t# sees an empty archive. Infozip will generate a warning and exit with\n'> <'\t# code 1. But in the name of sanity, we do not expect other unzip\n'> 
          <'\t# implementations to do the same thing (it would be perfectly\n'> <'\t# reasonable to exit 0, for example).\n'> <'\t#\n'> 
          <'\t# This makes our test less rigorous on some platforms (unzip may not\n'> <'\t# handle the empty repo at all, making our later check of its exit code\n'> 
          <'\t# a no-op). But we cannot do anything reasonable except skip the test\n'> <'\t# on such platforms anyway, and this is the moral equivalent.\n'> <'\t{\n'> 
          <'\t\t"$GIT_UNZIP" "$TEST_DIRECTORY"/t5004/empty.zip\n'> <'\t\texpect_code=$?\n'> <'\t} &&\n'> <'\n'> <'\tgit archive --format=zip HEAD >empty.zip &&\n'> 
          <'\tmake_dir extract &&\n'> <'\t(\n'> <'\t\tcd extract &&\n'> <'\t\ttest_expect_code $expect_code "$GIT_UNZIP" ../empty.zip\n'> 
          <'\t) &&\n'> <'\tcheck_dir extract\n'>
        )
      }
    )
    (C {(test_expect_success)} {(UNZIP)} {(SQ <'zip archive of empty tree with prefix'>)} 
      {
        (SQ <'\n'> <'\t# We do not have to play exit-code tricks here, because our\n'> 
          <'\t# result should not be empty; it has a directory in it.\n'> <'\tgit archive --format=zip --prefix=foo/ HEAD >prefix.zip &&\n'> <'\tmake_dir extract &&\n'> 
          <'\t(\n'> <'\t\tcd extract &&\n'> <'\t\t"$GIT_UNZIP" ../prefix.zip\n'> <'\t) &&\n'> <'\tcheck_dir extract foo\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'archive complains about pathspec on empty tree'>)} 
      {(SQ <'\n'> <'\ttest_must_fail git archive --format=tar HEAD -- foo >/dev/null\n'>)}
    )
    (C {(test_expect_success)} {(SQ <'create a commit with an empty subtree'>)} 
      {
        (SQ <'\n'> <'\tempty_tree=$(git hash-object -t tree /dev/null) &&\n'> 
          <'\troot_tree=$(printf "040000 tree $empty_tree\\tsub\\n" | git mktree)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'archive empty subtree with no pathspec'>)} 
      {
        (SQ <'\n'> <'\tgit archive --format=tar $root_tree >subtree-all.tar &&\n'> 
          <'\tmake_dir extract &&\n'> <'\t"$TAR" xf subtree-all.tar -C extract &&\n'> <'\tcheck_dir extract sub\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'archive empty subtree by direct pathspec'>)} 
      {
        (SQ <'\n'> <'\tgit archive --format=tar $root_tree -- sub >subtree-path.tar &&\n'> 
          <'\tmake_dir extract &&\n'> <'\t"$TAR" xf subtree-path.tar -C extract &&\n'> <'\tcheck_dir extract sub\n'>
        )
      }
    )
    (Assignment
      keyword: Assign_None
      pairs: [(assign_pair lhs:(LhsName name:ZIPINFO) op:Equal rhs:{(zipinfo)} spids:[353])]
      spids: [353]
    )
    (C {(test_lazy_prereq)} {(ZIPINFO)} 
      {
        (SQ <'\n'> <'\tn=$("$ZIPINFO" "$TEST_DIRECTORY"/t5004/empty.zip | sed -n "2s/.* //p")\n'> 
          <'\ttest "x$n" = "x0"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(ZIPINFO)} {(SQ <'zip archive with many entries'>)} 
      {
        (SQ <'\n'> <'\t# add a directory with 256 files\n'> <'\tmkdir 00 &&\n'> 
          <'\tfor a in 0 1 2 3 4 5 6 7 8 9 a b c d e f\n'> <'\tdo\n'> <'\t\tfor b in 0 1 2 3 4 5 6 7 8 9 a b c d e f\n'> <'\t\tdo\n'> <'\t\t\t: >00/$a$b\n'> 
          <'\t\tdone\n'> <'\tdone &&\n'> <'\tgit add 00 &&\n'> <'\tgit commit -m "256 files in 1 directory" &&\n'> <'\n'> 
          <'\t# duplicate it to get 65536 files in 256 directories\n'> <'\tsubtree=$(git write-tree --prefix=00/) &&\n'> <'\tfor c in 0 1 2 3 4 5 6 7 8 9 a b c d e f\n'> 
          <'\tdo\n'> <'\t\tfor d in 0 1 2 3 4 5 6 7 8 9 a b c d e f\n'> <'\t\tdo\n'> 
          <'\t\t\techo "040000 tree $subtree\t$c$d"\n'> <'\t\tdone\n'> <'\tdone >tree &&\n'> <'\ttree=$(git mktree <tree) &&\n'> <'\n'> <'\t# zip them\n'> 
          <'\tgit archive -o many.zip $tree &&\n'> <'\n'> <'\t# check the number of entries in the ZIP file directory\n'> 
          <'\texpr 65536 + 256 >expect &&\n'> <'\t"$ZIPINFO" many.zip | head -2 | sed -n "2s/.* //p" >actual &&\n'> <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {(test_done)})
  ]
)