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