(command.CommandList children: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:test_description) op: Equal rhs: {(SQ <'test corner cases of git-archive'>)} ) ] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(SQ <'create commit with empty tree'>)} {(SQ <'\n'> <'\tgit commit --allow-empty -m foo\n'>)} ) (command.FuncDef name: make_dir body: (command.BraceGroup children: [ (command.AndOr ops: [Op_DAmp] children: [ (C {(mkdir)} {(DQ ($ VSub_Number '$1'))}) (C {(test_when_finished)} {(DQ ("rm -rf '") ($ VSub_Number '$1') ("'"))}) ] ) ] ) ) (command.FuncDef name: check_dir body: (command.BraceGroup children: [ (command.Sentence child: (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:dir) op: Equal rhs: {($ VSub_Number '$1')} ) ] ) terminator: <Op_Semi ';'> ) (C {(shift)}) (command.AndOr ops: [Op_DAmp Op_DAmp] children: [ (command.Pipeline children: [ (command.BraceGroup children: [ (command.AndOr ops: [Op_DAmp] children: [ (C {(echo)} {(DQ ($ VSub_DollarName '$dir'))}) (command.ForEach iter_name: i iter_words: [{(DQ ($ VSub_At '$@'))}] do_arg_iter: F body: (command.DoGroup children: [ (C {(echo)} {(DQ ($ VSub_DollarName '$dir') (/) ($ VSub_DollarName '$i'))} ) ] ) ) ] ) ] ) (command.SimpleCommand words: [{(sort)}] redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(expect)})] ) ] negated: F ) (command.Pipeline children: [ (C {(find)} {(DQ ($ VSub_DollarName '$dir'))} {(KW_Bang '!')} {(-name)} {(pax_global_header)} {(-print)} ) (command.SimpleCommand words: [{(sort)}] redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(actual)})] ) ] negated: F ) (C {(test_cmp)} {(expect)} {(actual)}) ] ) ] ) ) (command.If arms: [ (if_arm cond: [ (command.SimpleCommand words: [ {(DQ ($ VSub_DollarName '$TAR'))} {(tf)} {(DQ ($ VSub_DollarName '$TEST_DIRECTORY')) (/t5004/empty-with-pax-header.tar)} ] redirects: [ (redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(/dev/null)}) (redir.Redir op:<Redir_GreatAnd '2>&'> fd:2 arg_word:{(1)}) ] ) ] action: [(C {(test_set_prereq)} {(HEADER_ONLY_TAR_OK)})] ) ] ) (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'> ) } ) (command.Assignment keyword: Assign_None pairs: [(assign_pair lhs:(lhs_expr.LhsName name:ZIPINFO) op:Equal rhs:{(zipinfo)})] ) (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)}) ] )