#!/bin/sh global test_description := ''ls-tree with(out) globs'' source ./test-lib.sh test_expect_success 'setup' ' mkdir a aa "a[a]" && touch a/one aa/two "a[a]/three" && git add a/one aa/two "a[a]/three" && git commit -m test ' test_expect_success 'ls-tree a[a] matches literally' ' cat >expect <<-EOF && 100644 blob $EMPTY_BLOB a[a]/three EOF git ls-tree -r HEAD "a[a]" >actual && test_cmp expect actual ' test_expect_success 'ls-tree outside prefix' ' cat >expect <<-EOF && 100644 blob $EMPTY_BLOB ../a[a]/three EOF ( cd aa && git ls-tree -r HEAD "../a[a]"; ) >actual && test_cmp expect actual ' test_expect_failure 'ls-tree does not yet support negated pathspec' ' git ls-files ":(exclude)a" "a*" >expect && git ls-tree --name-only -r HEAD ":(exclude)a" "a*" >actual && test_cmp expect actual ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"ls-tree with(out) globs">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(SQ )} { (SQ <"\n"> <"\tmkdir a aa \"a[a]\" &&\n"> <"\ttouch a/one aa/two \"a[a]/three\" &&\n"> <"\tgit add a/one aa/two \"a[a]/three\" &&\n"> <"\tgit commit -m test\n"> ) } ) (C {(test_expect_success)} {(SQ <"ls-tree a[a] matches literally">)} { (SQ <"\n"> <"\tcat >expect <<-EOF &&\n"> <"\t100644 blob $EMPTY_BLOB\ta[a]/three\n"> <"\tEOF\n"> <"\tgit ls-tree -r HEAD \"a[a]\" >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"ls-tree outside prefix">)} { (SQ <"\n"> <"\tcat >expect <<-EOF &&\n"> <"\t100644 blob $EMPTY_BLOB\t../a[a]/three\n"> <"\tEOF\n"> <"\t( cd aa && git ls-tree -r HEAD \"../a[a]\"; ) >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_failure)} {(SQ <"ls-tree does not yet support negated pathspec">)} { (SQ <"\n"> <"\tgit ls-files \":(exclude)a\" \"a*\" >expect &&\n"> <"\tgit ls-tree --name-only -r HEAD \":(exclude)a\" \"a*\" >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_done)}) ] )