(command.CommandList
  children: [
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:test_description)
          op: assign_op.Equal
          rhs: {(SQ <'git archive --format=zip test'>)}
          spids: [4]
        )
      ]
    )
    (C {<.>} {<'./test-lib.sh'>})
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:SUBSTFORMAT)
          op: assign_op.Equal
          rhs: {<Id.Lit_Other '%'> <H> <Id.Lit_Other '%'> <n>}
          spids: [15]
        )
      ]
    )
    (C {<test_lazy_prereq>} {<UNZIP_SYMLINKS>} 
      {
        (SQ <'\n'> <'\t(\n'> <'\t\tmkdir unzip-symlinks &&\n'> <'\t\tcd unzip-symlinks &&\n'> 
          <'\t\t"$GIT_UNZIP" "$TEST_DIRECTORY"/t5003/infozip-symlinks.zip &&\n'> <'\t\ttest -h symlink\n'> <'\t)\n'>
        )
      }
    )
    (command.ShFunction
      name: check_zip
      body: 
        (BraceGroup
          children: [
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:zipfile)
                  op: assign_op.Equal
                  rhs: {($ Id.VSub_Number '$1') <.zip>}
                  spids: [44]
                )
              ]
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:listfile)
                  op: assign_op.Equal
                  rhs: {($ Id.VSub_Number '$1') <.lst>}
                  spids: [49]
                )
              ]
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:dir)
                  op: assign_op.Equal
                  rhs: {($ Id.VSub_Number '$1')}
                  spids: [54]
                )
              ]
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:dir_with_prefix)
                  op: assign_op.Equal
                  rhs: {($ Id.VSub_DollarName '$dir') <'/'> ($ Id.VSub_Number '$2')}
                  spids: [58]
                )
              ]
            )
            (C {<test_expect_success>} {<UNZIP>} {(DQ <' extract ZIP archive'>)} 
              {(SQ <'\n'> <'\t\t(mkdir $dir && cd $dir && "$GIT_UNZIP" ../$zipfile)\n'> <'\t'>)}
            )
            (C {<test_expect_success>} {<UNZIP>} {(DQ <' validate filenames'>)} 
              {
                (DQ <'\n'> <'\t\t(cd '> (${ Id.VSub_Name dir_with_prefix) <'a && find .) | sort >'> 
                  ($ Id.VSub_DollarName '$listfile') <' &&\n'> <'\t\ttest_cmp a.lst '> ($ Id.VSub_DollarName '$listfile') <'\n'> <'\t'>
                )
              }
            )
            (C {<test_expect_success>} {<UNZIP>} {(DQ <' validate file contents'>)} 
              {(DQ <'\n'> <'\t\tdiff -r a '> (${ Id.VSub_Name dir_with_prefix) <'a\n'> <'\t'>)}
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:dir)
                  op: assign_op.Equal
                  rhs: {<eol_> ($ Id.VSub_Number '$1')}
                  spids: [126]
                )
              ]
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:dir_with_prefix)
                  op: assign_op.Equal
                  rhs: {($ Id.VSub_DollarName '$dir') <'/'> ($ Id.VSub_Number '$2')}
                  spids: [131]
                )
              ]
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:extracted)
                  op: assign_op.Equal
                  rhs: {(${ Id.VSub_Name dir_with_prefix) <a>}
                  spids: [137]
                )
              ]
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:original)
                  op: assign_op.Equal
                  rhs: {<a>}
                  spids: [144]
                )
              ]
            )
            (C {<test_expect_success>} {<UNZIP>} {(DQ <' extract ZIP archive with EOL conversion'>)} 
              {(SQ <'\n'> <'\t\t(mkdir $dir && cd $dir && "$GIT_UNZIP" -a ../$zipfile)\n'> <'\t'>)}
            )
            (C {<test_expect_success>} {<UNZIP>} {(DQ <' validate that text files are converted'>)} 
              {
                (DQ <'\n'> <'\t\ttest_cmp_bin '> ($ Id.VSub_DollarName '$extracted') <'/text.cr '> 
                  ($ Id.VSub_DollarName '$extracted') <'/text.crlf &&\n'> <'\t\ttest_cmp_bin '> ($ Id.VSub_DollarName '$extracted') <'/text.cr '> 
                  ($ Id.VSub_DollarName '$extracted') <'/text.lf\n'> <'\t'>
                )
              }
            )
            (C {<test_expect_success>} {<UNZIP>} {(DQ <' validate that binary files are unchanged'>)} 
              {
                (DQ <'\n'> <'\t\ttest_cmp_bin '> ($ Id.VSub_DollarName '$original') <'/binary.cr   '> 
                  ($ Id.VSub_DollarName '$extracted') <'/binary.cr &&\n'> <'\t\ttest_cmp_bin '> ($ Id.VSub_DollarName '$original') <'/binary.crlf '> 
                  ($ Id.VSub_DollarName '$extracted') <'/binary.crlf &&\n'> <'\t\ttest_cmp_bin '> ($ Id.VSub_DollarName '$original') <'/binary.lf   '> 
                  ($ Id.VSub_DollarName '$extracted') <'/binary.lf\n'> <'\t'>
                )
              }
            )
            (C {<test_expect_success>} {<UNZIP>} {(DQ <' validate that diff files are converted'>)} 
              {
                (DQ <'\n'> <'\t\ttest_cmp_bin '> ($ Id.VSub_DollarName '$extracted') <'/diff.cr '> 
                  ($ Id.VSub_DollarName '$extracted') <'/diff.crlf &&\n'> <'\t\ttest_cmp_bin '> ($ Id.VSub_DollarName '$extracted') <'/diff.cr '> 
                  ($ Id.VSub_DollarName '$extracted') <'/diff.lf\n'> <'\t'>
                )
              }
            )
            (C {<test_expect_success>} {<UNZIP>} {(DQ <' validate that -diff files are unchanged'>)} 
              {
                (DQ <'\n'> <'\t\ttest_cmp_bin '> ($ Id.VSub_DollarName '$original') <'/nodiff.cr   '> 
                  ($ Id.VSub_DollarName '$extracted') <'/nodiff.cr &&\n'> <'\t\ttest_cmp_bin '> ($ Id.VSub_DollarName '$original') <'/nodiff.crlf '> 
                  ($ Id.VSub_DollarName '$extracted') <'/nodiff.crlf &&\n'> <'\t\ttest_cmp_bin '> ($ Id.VSub_DollarName '$original') <'/nodiff.lf   '> 
                  ($ Id.VSub_DollarName '$extracted') <'/nodiff.lf\n'> <'\t'>
                )
              }
            )
          ]
        )
    )
    (C {<test_expect_success>} {(SQ <'populate workdir'>)} 
      {
        (SQ <'mkdir a &&\n'> <'     echo simple textfile >a/a &&\n'> <'     mkdir a/bin &&\n'> 
          <'     cp /bin/sh a/bin &&\n'> <'     printf "text\\r"\t>a/text.cr &&\n'> <'     printf "text\\r\\n"\t>a/text.crlf &&\n'> 
          <'     printf "text\\n"\t>a/text.lf &&\n'> <'     printf "text\\r"\t>a/nodiff.cr &&\n'> <'     printf "text\\r\\n"\t>a/nodiff.crlf &&\n'> 
          <'     printf "text\\n"\t>a/nodiff.lf &&\n'> <'     printf "\\0\\r"\t>a/binary.cr &&\n'> <'     printf "\\0\\r\\n"\t>a/binary.crlf &&\n'> 
          <'     printf "\\0\\n"\t>a/binary.lf &&\n'> <'     printf "\\0\\r"\t>a/diff.cr &&\n'> <'     printf "\\0\\r\\n"\t>a/diff.crlf &&\n'> 
          <'     printf "\\0\\n"\t>a/diff.lf &&\n'> <'     printf "A\\$Format:%s\\$O" "$SUBSTFORMAT" >a/substfile1 &&\n'> 
          <'     printf "A not substituted O" >a/substfile2 &&\n'> <'     (p=long_path_to_a_file && cd a &&\n'> 
          <'      for depth in 1 2 3 4 5; do mkdir $p && cd $p; done &&\n'> <'      echo text >file_with_long_path)\n'>
        )
      }
    )
    (C {<test_expect_success>} {<SYMLINKS> <Id.Lit_Comma ','> <UNZIP_SYMLINKS>} {(SQ <'add symlink'>)} 
      {(SQ <'\n'> <'\tln -s a a/symlink_to_a\n'>)}
    )
    (C {<test_expect_success>} {(SQ <'prepare file list'>)} 
      {(SQ <'\n'> <'\t(cd a && find .) | sort >a.lst\n'>)}
    )
    (C {<test_expect_success>} {(SQ <'add ignored file'>)} 
      {
        (SQ <'echo ignore me >a/ignored &&\n'> 
          <'     echo ignored export-ignore >.git/info/attributes'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'add files to repository'>)} 
      {
        (SQ <'\n'> <'\tgit add a &&\n'> 
          <'\tGIT_COMMITTER_DATE="2005-05-27 22:00" git commit -m initial\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'setup export-subst and diff attributes'>)} 
      {
        (SQ <'\n'> <'\techo "a/nodiff.* -diff" >>.git/info/attributes &&\n'> 
          <'\techo "a/diff.* diff" >>.git/info/attributes &&\n'> <'\techo "substfile?" export-subst >>.git/info/attributes &&\n'> 
          <'\tgit log --max-count=1 "--pretty=format:A${SUBSTFORMAT}O" HEAD \\\n'> <'\t\t>a/substfile1\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'create bare clone'>)} 
      {
        (SQ <'git clone --bare . bare.git &&\n'> 
          <'     cp .git/info/attributes bare.git/info/attributes'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'remove ignored file'>)} {(SQ <'rm a/ignored'>)})
    (C {<test_expect_success>} {(SQ <'git archive --format=zip'>)} 
      {(SQ <'git archive --format=zip HEAD >d.zip'>)}
    )
    (C {<check_zip>} {<d>})
    (C {<test_expect_success>} {(SQ <'git archive --format=zip in a bare repo'>)} 
      {(SQ <'(cd bare.git && git archive --format=zip HEAD) >d1.zip'>)}
    )
    (C {<test_expect_success>} {(SQ <'git archive --format=zip vs. the same in a bare repo'>)} 
      {(SQ <'test_cmp_bin d.zip d1.zip'>)}
    )
    (C {<test_expect_success>} {(SQ <'git archive --format=zip with --output'>)} 
      {(SQ <'git archive --format=zip --output=d2.zip HEAD &&\n'> <'    test_cmp_bin d.zip d2.zip'>)}
    )
    (C {<test_expect_success>} {(SQ <'git archive with --output, inferring format'>)} 
      {(SQ <'\n'> <'\tgit archive --output=d3.zip HEAD &&\n'> <'\ttest_cmp_bin d.zip d3.zip\n'>)}
    )
    (C {<test_expect_success>} {(SQ <'git archive --format=zip with prefix'>)} 
      {(SQ <'git archive --format=zip --prefix=prefix/ HEAD >e.zip'>)}
    )
    (C {<check_zip>} {<e>} {<'prefix/'>})
    (C {<test_expect_success>} {(SQ <'git archive -0 --format=zip on large files'>)} 
      {
        (SQ <'\n'> <'\ttest_config core.bigfilethreshold 1 &&\n'> 
          <'\tgit archive -0 --format=zip HEAD >large.zip\n'>
        )
      }
    )
    (C {<check_zip>} {<large>})
    (C {<test_expect_success>} {(SQ <'git archive --format=zip on large files'>)} 
      {
        (SQ <'\n'> <'\ttest_config core.bigfilethreshold 1 &&\n'> 
          <'\tgit archive --format=zip HEAD >large-compressed.zip\n'>
        )
      }
    )
    (C {<check_zip>} {<large-compressed>})
    (C {<test_done>})
  ]
)