t: use common $SQ variable
[git/git.git] / t / t3005-ls-files-relative.sh
1 #!/bin/sh
2
3 test_description='ls-files tests with relative paths
4
5 This test runs git ls-files with various relative path arguments.
6 '
7
8 . ./test-lib.sh
9
10 new_line='
11 '
12
13 test_expect_success 'prepare' '
14 : >never-mind-me &&
15 git add never-mind-me &&
16 mkdir top &&
17 (
18 cd top &&
19 mkdir sub &&
20 x="x xa xbc xdef xghij xklmno" &&
21 y=$(echo "$x" | tr x y) &&
22 touch $x &&
23 touch $y &&
24 cd sub &&
25 git add ../x*
26 )
27 '
28
29 test_expect_success 'ls-files with mixed levels' '
30 (
31 cd top/sub &&
32 cat >expect <<-EOF &&
33 ../../never-mind-me
34 ../x
35 EOF
36 git ls-files $(cat expect) >actual &&
37 test_cmp expect actual
38 )
39 '
40
41 test_expect_success 'ls-files -c' '
42 (
43 cd top/sub &&
44 for f in ../y*
45 do
46 echo "error: pathspec $SQ$f$SQ did not match any file(s) known to git"
47 done >expect.err &&
48 echo "Did you forget to ${SQ}git add${SQ}?" >>expect.err &&
49 ls ../x* >expect.out &&
50 test_must_fail git ls-files -c --error-unmatch ../[xy]* >actual.out 2>actual.err &&
51 test_cmp expect.out actual.out &&
52 test_i18ncmp expect.err actual.err
53 )
54 '
55
56 test_expect_success 'ls-files -o' '
57 (
58 cd top/sub &&
59 for f in ../x*
60 do
61 echo "error: pathspec $SQ$f$SQ did not match any file(s) known to git"
62 done >expect.err &&
63 echo "Did you forget to ${SQ}git add${SQ}?" >>expect.err &&
64 ls ../y* >expect.out &&
65 test_must_fail git ls-files -o --error-unmatch ../[xy]* >actual.out 2>actual.err &&
66 test_cmp expect.out actual.out &&
67 test_i18ncmp expect.err actual.err
68 )
69 '
70
71 test_done