]>
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" |
25482a3c JS |
18 | test -f "Name and an${HT}HT" || { |
19 | # since FAT/NTFS does not allow tabs in filenames, skip this test | |
20 | say 'Your filesystem does not allow tabs in filenames, test skipped.' | |
21 | test_done | |
22 | } | |
23 | ||
9378c161 JH |
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" | |
29 | do | |
30 | eval "$1" | |
31 | done | |
32 | } | |
33 | ||
34 | test_expect_success setup ' | |
35 | ||
36 | for_each_name "echo initial >\"\$name\"" | |
37 | git add . && | |
38 | git commit -q -m Initial && | |
39 | ||
40 | for_each_name "echo second >\"\$name\"" && | |
41 | git commit -a -m Second | |
42 | ||
43 | for_each_name "echo modified >\"\$name\"" | |
44 | ||
45 | ' | |
46 | ||
47 | cat >expect.quoted <<\EOF | |
48 | Name | |
49 | "Name and a\nLF" | |
50 | "Name and an\tHT" | |
51 | "Name\"" | |
52 | With SP in it | |
53 | "\346\277\261\351\207\216\t\347\264\224" | |
54 | "\346\277\261\351\207\216\n\347\264\224" | |
55 | "\346\277\261\351\207\216 \347\264\224" | |
56 | "\346\277\261\351\207\216\"\347\264\224" | |
57 | "\346\277\261\351\207\216\347\264\224" | |
58 | EOF | |
59 | ||
60 | cat >expect.raw <<\EOF | |
61 | Name | |
62 | "Name and a\nLF" | |
63 | "Name and an\tHT" | |
64 | "Name\"" | |
65 | With SP in it | |
66 | "濱野\t純" | |
67 | "濱野\n純" | |
68 | 濱野 純 | |
69 | "濱野\"純" | |
70 | 濱野純 | |
71 | EOF | |
72 | ||
73 | test_expect_success 'check fully quoted output from ls-files' ' | |
74 | ||
82ebb0b6 | 75 | git ls-files >current && test_cmp expect.quoted current |
9378c161 JH |
76 | |
77 | ' | |
78 | ||
79 | test_expect_success 'check fully quoted output from diff-files' ' | |
80 | ||
81 | git diff --name-only >current && | |
82ebb0b6 | 82 | test_cmp expect.quoted current |
9378c161 JH |
83 | |
84 | ' | |
85 | ||
86 | test_expect_success 'check fully quoted output from diff-index' ' | |
87 | ||
88 | git diff --name-only HEAD >current && | |
82ebb0b6 | 89 | test_cmp expect.quoted current |
9378c161 JH |
90 | |
91 | ' | |
92 | ||
93 | test_expect_success 'check fully quoted output from diff-tree' ' | |
94 | ||
95 | git diff --name-only HEAD^ HEAD >current && | |
82ebb0b6 | 96 | test_cmp expect.quoted current |
9378c161 JH |
97 | |
98 | ' | |
99 | ||
100 | test_expect_success 'setting core.quotepath' ' | |
101 | ||
102 | git config --bool core.quotepath false | |
103 | ||
104 | ' | |
105 | ||
106 | test_expect_success 'check fully quoted output from ls-files' ' | |
107 | ||
82ebb0b6 | 108 | git ls-files >current && test_cmp expect.raw current |
9378c161 JH |
109 | |
110 | ' | |
111 | ||
112 | test_expect_success 'check fully quoted output from diff-files' ' | |
113 | ||
114 | git diff --name-only >current && | |
82ebb0b6 | 115 | test_cmp expect.raw current |
9378c161 JH |
116 | |
117 | ' | |
118 | ||
119 | test_expect_success 'check fully quoted output from diff-index' ' | |
120 | ||
121 | git diff --name-only HEAD >current && | |
82ebb0b6 | 122 | test_cmp expect.raw current |
9378c161 JH |
123 | |
124 | ' | |
125 | ||
126 | test_expect_success 'check fully quoted output from diff-tree' ' | |
127 | ||
128 | git diff --name-only HEAD^ HEAD >current && | |
82ebb0b6 | 129 | test_cmp expect.raw current |
9378c161 JH |
130 | |
131 | ' | |
132 | ||
133 | test_done |