ls-files: fix a trivial dir_clear() leak
[git/debian.git] / t / t3005-ls-files-relative.sh
blob6ba8b589cd00d3ad401f4018dc0eed7be1b54e05
1 #!/bin/sh
3 test_description='ls-files tests with relative paths
5 This test runs git ls-files with various relative path arguments.
8 TEST_PASSES_SANITIZE_LEAK=true
9 . ./test-lib.sh
11 test_expect_success 'prepare' '
12 : >never-mind-me &&
13 git add never-mind-me &&
14 mkdir top &&
16 cd top &&
17 mkdir sub &&
18 x="x xa xbc xdef xghij xklmno" &&
19 y=$(echo "$x" | tr x y) &&
20 touch $x &&
21 touch $y &&
22 cd sub &&
23 git add ../x*
27 test_expect_success 'ls-files with mixed levels' '
29 cd top/sub &&
30 cat >expect <<-EOF &&
31 ../../never-mind-me
32 ../x
33 EOF
34 git ls-files $(cat expect) >actual &&
35 test_cmp expect actual
39 test_expect_success 'ls-files -c' '
41 cd top/sub &&
42 for f in ../y*
44 echo "error: pathspec $SQ$f$SQ did not match any file(s) known to git"
45 done >expect.err &&
46 echo "Did you forget to ${SQ}git add${SQ}?" >>expect.err &&
47 ls ../x* >expect.out &&
48 test_must_fail git ls-files -c --error-unmatch ../[xy]* >actual.out 2>actual.err &&
49 test_cmp expect.out actual.out &&
50 test_cmp expect.err actual.err
54 test_expect_success 'ls-files -o' '
56 cd top/sub &&
57 for f in ../x*
59 echo "error: pathspec $SQ$f$SQ did not match any file(s) known to git"
60 done >expect.err &&
61 echo "Did you forget to ${SQ}git add${SQ}?" >>expect.err &&
62 ls ../y* >expect.out &&
63 test_must_fail git ls-files -o --error-unmatch ../[xy]* >actual.out 2>actual.err &&
64 test_cmp expect.out actual.out &&
65 test_cmp expect.err actual.err
69 test_done