(command.CommandList children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:test_description) op: assign_op.Equal rhs: {(SQ <'test corner cases of git-archive'>)} 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'>)} ) (command.ShFunction name: make_dir body: (BraceGroup children: [ (command.AndOr ops: [Id.Op_DAmp] children: [ (C {<mkdir>} {(DQ ($ Id.VSub_Number '$1'))}) (C {<test_when_finished>} {(DQ <'rm -rf \''> ($ Id.VSub_Number '$1') <'\''>)}) ] ) ] ) ) (command.ShFunction name: check_dir body: (BraceGroup children: [ (command.Sentence child: (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:dir) op: assign_op.Equal rhs: {($ Id.VSub_Number '$1')} spids: [69] ) ] ) terminator: <Id.Op_Semi _> ) (C {<shift>}) (command.AndOr ops: [Id.Op_DAmp Id.Op_DAmp] children: [ (command.Pipeline children: [ (BraceGroup children: [ (command.AndOr ops: [Id.Op_DAmp] children: [ (C {<echo>} {(DQ ($ Id.VSub_DollarName '$dir'))}) (command.ForEach iter_names: [i] iterable: (for_iter.Words words:[{(DQ ($ Id.VSub_At '$@'))}]) body: (command.DoGroup children: [ (C {<echo>} { (DQ ($ Id.VSub_DollarName '$dir') <'/'> ($ Id.VSub_DollarName '$i') ) } ) ] ) ) ] ) ] ) (command.Simple words: [{<sort>}] redirects: [ (redir op: <Id.Redir_Great '>'> loc: (redir_loc.Fd fd:1) arg: {<expect>} ) ] do_fork: T ) ] negated: F ) (command.Pipeline children: [ (C {<find>} {(DQ ($ Id.VSub_DollarName '$dir'))} {<Id.KW_Bang '!'>} {<-name>} {<pax_global_header>} {<-print>} ) (command.Simple words: [{<sort>}] redirects: [ (redir op: <Id.Redir_Great '>'> loc: (redir_loc.Fd fd:1) arg: {<actual>} ) ] do_fork: T ) ] negated: F ) (C {<test_cmp>} {<expect>} {<actual>}) ] ) ] ) ) (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (command.Simple words: [ {(DQ ($ Id.VSub_DollarName '$TAR'))} {<tf>} {(DQ ($ Id.VSub_DollarName '$TEST_DIRECTORY')) <'/t5004/empty-with-pax-header.tar'> } ] redirects: [ (redir op: <Id.Redir_Great '>'> loc: (redir_loc.Fd fd:1) arg: {<'/dev/null'>} ) (redir op: <Id.Redir_GreatAnd '2>&'> loc: (redir_loc.Fd fd:2) arg: {<1>} ) ] do_fork: T ) ] ) action: [(C {<test_set_prereq>} {<HEADER_ONLY_TAR_OK>})] spids: [166 185] ) ] ) (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.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:ZIPINFO) op: assign_op.Equal rhs: {<zipinfo>} 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>}) ] )