Merge branch 'hd/show-one-mergetag-fix'
[git] / t / t0067-parse_pathspec_file.sh
1 #!/bin/sh
2
3 test_description='Test parse_pathspec_file()'
4
5 . ./test-lib.sh
6
7 test_expect_success 'one item from stdin' '
8         cat >expect <<-\EOF &&
9         fileA.t
10         EOF
11
12         echo fileA.t |
13         test-tool parse-pathspec-file --pathspec-from-file=- >actual &&
14
15         test_cmp expect actual
16 '
17
18 test_expect_success 'one item from file' '
19         cat >expect <<-\EOF &&
20         fileA.t
21         EOF
22
23         echo fileA.t >list &&
24         test-tool parse-pathspec-file --pathspec-from-file=list >actual &&
25
26         test_cmp expect actual
27 '
28
29 test_expect_success 'NUL delimiters' '
30         cat >expect <<-\EOF &&
31         fileA.t
32         fileB.t
33         EOF
34
35         printf "fileA.t\0fileB.t\0" |
36         test-tool parse-pathspec-file --pathspec-from-file=- --pathspec-file-nul >actual &&
37
38         test_cmp expect actual
39 '
40
41 test_expect_success 'LF delimiters' '
42         cat >expect <<-\EOF &&
43         fileA.t
44         fileB.t
45         EOF
46
47         printf "fileA.t\nfileB.t\n" |
48         test-tool parse-pathspec-file --pathspec-from-file=- >actual &&
49
50         test_cmp expect actual
51 '
52
53 test_expect_success 'no trailing delimiter' '
54         cat >expect <<-\EOF &&
55         fileA.t
56         fileB.t
57         EOF
58
59         printf "fileA.t\nfileB.t" |
60         test-tool parse-pathspec-file --pathspec-from-file=- >actual &&
61
62         test_cmp expect actual
63 '
64
65 test_expect_success 'CRLF delimiters' '
66         cat >expect <<-\EOF &&
67         fileA.t
68         fileB.t
69         EOF
70
71         printf "fileA.t\r\nfileB.t\r\n" |
72         test-tool parse-pathspec-file --pathspec-from-file=- >actual &&
73
74         test_cmp expect actual
75 '
76
77 test_expect_success 'quotes' '
78         cat >expect <<-\EOF &&
79         fileA.t
80         EOF
81
82         cat >list <<-\EOF &&
83         "file\101.t"
84         EOF
85
86         test-tool parse-pathspec-file --pathspec-from-file=list >actual &&
87
88         test_cmp expect actual
89 '
90
91 test_expect_success '--pathspec-file-nul takes quotes literally' '
92         # Note: there is an extra newline because --pathspec-file-nul takes
93         # input \n literally, too
94         cat >expect <<-\EOF &&
95         "file\101.t"
96
97         EOF
98
99         cat >list <<-\EOF &&
100         "file\101.t"
101         EOF
102
103         test-tool parse-pathspec-file --pathspec-from-file=list --pathspec-file-nul >actual &&
104
105         test_cmp expect actual
106 '
107
108 test_done