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