]> git.ipfire.org Git - thirdparty/git.git/blob - t/t3902-quoted.sh
147e634cd65b616ea6c8059897f191b761996c6f
[thirdparty/git.git] / t / t3902-quoted.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2006 Junio C Hamano
4 #
5
6 test_description='quoted output'
7
8 . ./test-lib.sh
9
10 FN='濱野'
11 GN='純'
12 HT=' '
13 LF='
14 '
15 DQ='"'
16
17 echo foo 2>/dev/null > "Name and an${HT}HT"
18 test -f "Name and an${HT}HT" || {
19 # since FAT/NTFS does not allow tabs in filenames, skip this test
20 skip_all='Your filesystem does not allow tabs in filenames, test skipped.'
21 test_done
22 }
23
24 for_each_name () {
25 for name in \
26 Name "Name and a${LF}LF" "Name and an${HT}HT" "Name${DQ}" \
27 "$FN$HT$GN" "$FN$LF$GN" "$FN $GN" "$FN$GN" "$FN$DQ$GN" \
28 "With SP in it" "$FN/file"
29 do
30 eval "$1"
31 done
32 }
33
34 test_expect_success setup '
35
36 mkdir "$FN" &&
37 for_each_name "echo initial >\"\$name\""
38 git add . &&
39 git commit -q -m Initial &&
40
41 for_each_name "echo second >\"\$name\"" &&
42 git commit -a -m Second
43
44 for_each_name "echo modified >\"\$name\""
45
46 '
47
48 cat >expect.quoted <<\EOF
49 Name
50 "Name and a\nLF"
51 "Name and an\tHT"
52 "Name\""
53 With SP in it
54 "\346\277\261\351\207\216\t\347\264\224"
55 "\346\277\261\351\207\216\n\347\264\224"
56 "\346\277\261\351\207\216 \347\264\224"
57 "\346\277\261\351\207\216\"\347\264\224"
58 "\346\277\261\351\207\216/file"
59 "\346\277\261\351\207\216\347\264\224"
60 EOF
61
62 cat >expect.raw <<\EOF
63 Name
64 "Name and a\nLF"
65 "Name and an\tHT"
66 "Name\""
67 With SP in it
68 "濱野\t純"
69 "濱野\n純"
70 濱野 純
71 "濱野\"純"
72 濱野/file
73 濱野純
74 EOF
75
76 test_expect_success 'check fully quoted output from ls-files' '
77
78 git ls-files >current && test_cmp expect.quoted current
79
80 '
81
82 test_expect_success 'check fully quoted output from diff-files' '
83
84 git diff --name-only >current &&
85 test_cmp expect.quoted current
86
87 '
88
89 test_expect_success 'check fully quoted output from diff-index' '
90
91 git diff --name-only HEAD >current &&
92 test_cmp expect.quoted current
93
94 '
95
96 test_expect_success 'check fully quoted output from diff-tree' '
97
98 git diff --name-only HEAD^ HEAD >current &&
99 test_cmp expect.quoted current
100
101 '
102
103 test_expect_success 'check fully quoted output from ls-tree' '
104
105 git ls-tree --name-only -r HEAD >current &&
106 test_cmp expect.quoted current
107
108 '
109
110 test_expect_success 'setting core.quotepath' '
111
112 git config --bool core.quotepath false
113
114 '
115
116 test_expect_success 'check fully quoted output from ls-files' '
117
118 git ls-files >current && test_cmp expect.raw current
119
120 '
121
122 test_expect_success 'check fully quoted output from diff-files' '
123
124 git diff --name-only >current &&
125 test_cmp expect.raw current
126
127 '
128
129 test_expect_success 'check fully quoted output from diff-index' '
130
131 git diff --name-only HEAD >current &&
132 test_cmp expect.raw current
133
134 '
135
136 test_expect_success 'check fully quoted output from diff-tree' '
137
138 git diff --name-only HEAD^ HEAD >current &&
139 test_cmp expect.raw current
140
141 '
142
143 test_expect_success 'check fully quoted output from ls-tree' '
144
145 git ls-tree --name-only -r HEAD >current &&
146 test_cmp expect.raw current
147
148 '
149
150 test_done