Raw
1 #!/bin/sh
2 #
3 # Copyright (c) 2005 Junio C Hamano
4 #
5
6 test_description='git ls-files test (-- to terminate the path list).
7
8 This test runs git ls-files --others with the following on the
9 filesystem.
10
11 path0 - a file
12 -foo - a file with a funny name.
13 -- - another file with a funny name.
14 '
15
16 . ./test-lib.sh
17
18 test_expect_success 'setup' '
19 echo frotz >path0 &&
20 echo frotz >./-foo &&
21 echo frotz >./--
22 '
23
24 test_expect_success 'git ls-files without path restriction.' '
25 test_when_finished "rm -f expect" &&
26 git ls-files --others >output &&
27 test_filter_gitconfig output &&
28 cat >expect <<-\EOF &&
29 --
30 -foo
31 output
32 path0
33 EOF
34 test_cmp output expect
35 '
36
37 test_expect_success 'git ls-files with path restriction.' '
38 test_when_finished "rm -f expect" &&
39 git ls-files --others path0 >output &&
40 cat >expect <<-\EOF &&
41 path0
42 EOF
43 test_cmp output expect
44 '
45
46 test_expect_success 'git ls-files with path restriction with --.' '
47 test_when_finished "rm -f expect" &&
48 git ls-files --others -- path0 >output &&
49 cat >expect <<-\EOF &&
50 path0
51 EOF
52 test_cmp output expect
53 '
54
55 test_expect_success 'git ls-files with path restriction with -- --.' '
56 test_when_finished "rm -f expect" &&
57 git ls-files --others -- -- >output &&
58 cat >expect <<-\EOF &&
59 --
60 EOF
61 test_cmp output expect
62 '
63
64 test_expect_success 'git ls-files with no path restriction.' '
65 test_when_finished "rm -f expect" &&
66 git ls-files --others -- >output &&
67 test_filter_gitconfig output &&
68 cat >expect <<-\EOF &&
69 --
70 -foo
71 output
72 path0
73 EOF
74 test_cmp output expect
75
76 '
77
78 test_done