Merge branch 'ms/rebase-insnformat-doc-fix' into maint-2.43
[git.git] / t / t3902-quoted.sh
blob72a5a565e973ad634ecfa4418d8934d3c7b85ae1
1 #!/bin/sh
3 # Copyright (c) 2006 Junio C Hamano
6 test_description='quoted output'
8 TEST_PASSES_SANITIZE_LEAK=true
9 . ./test-lib.sh
11 FN='濱野'
12 GN='純'
13 HT=' '
14 DQ='"'
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
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"
31 eval "$1"
32 done
35 test_expect_success 'setup' '
37 mkdir "$FN" &&
38 for_each_name "echo initial >\"\$name\"" &&
39 git add . &&
40 git commit -q -m Initial &&
42 for_each_name "echo second >\"\$name\"" &&
43 git commit -a -m Second &&
45 for_each_name "echo modified >\"\$name\""
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
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
79 test_expect_success 'check fully quoted output from ls-files' '
81 git ls-files >current && test_cmp expect.quoted current
85 test_expect_success 'check fully quoted output from diff-files' '
87 git diff --name-only >current &&
88 test_cmp expect.quoted current
92 test_expect_success 'check fully quoted output from diff-index' '
94 git diff --name-only HEAD >current &&
95 test_cmp expect.quoted current
99 test_expect_success 'check fully quoted output from diff-tree' '
101 git diff --name-only HEAD^ HEAD >current &&
102 test_cmp expect.quoted current
106 test_expect_success 'check fully quoted output from ls-tree' '
108 git ls-tree --name-only -r HEAD >current &&
109 test_cmp expect.quoted current
113 test_expect_success 'setting core.quotepath' '
115 git config --bool core.quotepath false
119 test_expect_success 'check fully quoted output from ls-files' '
121 git ls-files >current && test_cmp expect.raw current
125 test_expect_success 'check fully quoted output from diff-files' '
127 git diff --name-only >current &&
128 test_cmp expect.raw current
132 test_expect_success 'check fully quoted output from diff-index' '
134 git diff --name-only HEAD >current &&
135 test_cmp expect.raw current
139 test_expect_success 'check fully quoted output from diff-tree' '
141 git diff --name-only HEAD^ HEAD >current &&
142 test_cmp expect.raw current
146 test_expect_success 'check fully quoted output from ls-tree' '
148 git ls-tree --name-only -r HEAD >current &&
149 test_cmp expect.raw current
153 test_done