Merge branch 'maint'
[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 for_each_name () {
18         for name in \
19             Name "Name and a${LF}LF" "Name and an${HT}HT" "Name${DQ}" \
20             "$FN$HT$GN" "$FN$LF$GN" "$FN $GN" "$FN$GN" "$FN$DQ$GN" \
21             "With SP in it"
22         do
23                 eval "$1"
24         done
25 }
26
27 test_expect_success setup '
28
29         for_each_name "echo initial >\"\$name\""
30         git add . &&
31         git commit -q -m Initial &&
32
33         for_each_name "echo second >\"\$name\"" &&
34         git commit -a -m Second
35
36         for_each_name "echo modified >\"\$name\""
37
38 '
39
40 cat >expect.quoted <<\EOF
41 Name
42 "Name and a\nLF"
43 "Name and an\tHT"
44 "Name\""
45 With SP in it
46 "\346\277\261\351\207\216\t\347\264\224"
47 "\346\277\261\351\207\216\n\347\264\224"
48 "\346\277\261\351\207\216 \347\264\224"
49 "\346\277\261\351\207\216\"\347\264\224"
50 "\346\277\261\351\207\216\347\264\224"
51 EOF
52
53 cat >expect.raw <<\EOF
54 Name
55 "Name and a\nLF"
56 "Name and an\tHT"
57 "Name\""
58 With SP in it
59 "濱野\t純"
60 "濱野\n純"
61 濱野 純
62 "濱野\"純"
63 濱野純
64 EOF
65
66 test_expect_success 'check fully quoted output from ls-files' '
67
68         git ls-files >current && diff -u expect.quoted current
69
70 '
71
72 test_expect_success 'check fully quoted output from diff-files' '
73
74         git diff --name-only >current &&
75         diff -u expect.quoted current
76
77 '
78
79 test_expect_success 'check fully quoted output from diff-index' '
80
81         git diff --name-only HEAD >current &&
82         diff -u expect.quoted current
83
84 '
85
86 test_expect_success 'check fully quoted output from diff-tree' '
87
88         git diff --name-only HEAD^ HEAD >current &&
89         diff -u expect.quoted current
90
91 '
92
93 test_expect_success 'setting core.quotepath' '
94
95         git config --bool core.quotepath false
96
97 '
98
99 test_expect_success 'check fully quoted output from ls-files' '
100
101         git ls-files >current && diff -u expect.raw current
102
103 '
104
105 test_expect_success 'check fully quoted output from diff-files' '
106
107         git diff --name-only >current &&
108         diff -u expect.raw current
109
110 '
111
112 test_expect_success 'check fully quoted output from diff-index' '
113
114         git diff --name-only HEAD >current &&
115         diff -u expect.raw current
116
117 '
118
119 test_expect_success 'check fully quoted output from diff-tree' '
120
121         git diff --name-only HEAD^ HEAD >current &&
122         diff -u expect.raw current
123
124 '
125
126 test_done