#!/bin/sh global test_description := ''git mktree'' source ./test-lib.sh test_expect_success setup ' for d in a a. a0 do mkdir "$d" && echo "$d/one" >"$d/one" && git add "$d" done && echo zero >one && git update-index --add --info-only one && git write-tree --missing-ok >tree.missing && git ls-tree $(cat tree.missing) >top.missing && git ls-tree -r $(cat tree.missing) >all.missing && echo one >one && git add one && git write-tree >tree && git ls-tree $(cat tree) >top && git ls-tree -r $(cat tree) >all && test_tick && git commit -q -m one && H=$(git rev-parse HEAD) && git update-index --add --cacheinfo 160000 $H sub && test_tick && git commit -q -m two && git rev-parse HEAD^{tree} >tree.withsub && git ls-tree HEAD >top.withsub && git ls-tree -r HEAD >all.withsub ' test_expect_success 'ls-tree piped to mktree (1)' ' git mktree actual && test_cmp tree actual ' test_expect_success 'ls-tree piped to mktree (2)' ' git mktree actual && test_cmp tree.withsub actual ' test_expect_success 'ls-tree output in wrong order given to mktree (1)' ' perl -e "print reverse <>" actual && test_cmp tree actual ' test_expect_success 'ls-tree output in wrong order given to mktree (2)' ' perl -e "print reverse <>" actual && test_cmp tree.withsub actual ' test_expect_success 'allow missing object with --missing' ' git mktree --missing actual && test_cmp tree.missing actual ' test_expect_success 'mktree refuses to read ls-tree -r output (1)' ' test_must_fail git mktree actual ' test_expect_success 'mktree refuses to read ls-tree -r output (2)' ' test_must_fail git mktree actual ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"git mktree">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(setup)} { (SQ <"\n"> <"\tfor d in a a. a0\n"> <"\tdo\n"> <"\t\tmkdir \"$d\" && echo \"$d/one\" >\"$d/one\" &&\n"> <"\t\tgit add \"$d\"\n"> <"\tdone &&\n"> <"\techo zero >one &&\n"> <"\tgit update-index --add --info-only one &&\n"> <"\tgit write-tree --missing-ok >tree.missing &&\n"> <"\tgit ls-tree $(cat tree.missing) >top.missing &&\n"> <"\tgit ls-tree -r $(cat tree.missing) >all.missing &&\n"> <"\techo one >one &&\n"> <"\tgit add one &&\n"> <"\tgit write-tree >tree &&\n"> <"\tgit ls-tree $(cat tree) >top &&\n"> <"\tgit ls-tree -r $(cat tree) >all &&\n"> <"\ttest_tick &&\n"> <"\tgit commit -q -m one &&\n"> <"\tH=$(git rev-parse HEAD) &&\n"> <"\tgit update-index --add --cacheinfo 160000 $H sub &&\n"> <"\ttest_tick &&\n"> <"\tgit commit -q -m two &&\n"> <"\tgit rev-parse HEAD^{tree} >tree.withsub &&\n"> <"\tgit ls-tree HEAD >top.withsub &&\n"> <"\tgit ls-tree -r HEAD >all.withsub\n"> ) } ) (C {(test_expect_success)} {(SQ <"ls-tree piped to mktree (1)">)} {(SQ <"\n"> <"\tgit mktree actual &&\n"> <"\ttest_cmp tree actual\n">)} ) (C {(test_expect_success)} {(SQ <"ls-tree piped to mktree (2)">)} {(SQ <"\n"> <"\tgit mktree actual &&\n"> <"\ttest_cmp tree.withsub actual\n">)} ) (C {(test_expect_success)} {(SQ <"ls-tree output in wrong order given to mktree (1)">)} { (SQ <"\n"> <"\tperl -e \"print reverse <>\" <"\tgit mktree >actual &&\n"> <"\ttest_cmp tree actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"ls-tree output in wrong order given to mktree (2)">)} { (SQ <"\n"> <"\tperl -e \"print reverse <>\" <"\tgit mktree >actual &&\n"> <"\ttest_cmp tree.withsub actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"allow missing object with --missing">)} { (SQ <"\n"> <"\tgit mktree --missing actual &&\n"> <"\ttest_cmp tree.missing actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"mktree refuses to read ls-tree -r output (1)">)} {(SQ <"\n"> <"\ttest_must_fail git mktree actual\n">)} ) (C {(test_expect_success)} {(SQ <"mktree refuses to read ls-tree -r output (2)">)} {(SQ <"\n"> <"\ttest_must_fail git mktree actual\n">)} ) (C {(test_done)}) ] )