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