t3902-quoted.sh 2.77 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#!/bin/sh
#
# Copyright (c) 2006 Junio C Hamano
#

test_description='quoted output'

. ./test-lib.sh

FN='濱野'
GN='純'
HT='	'
DQ='"'

15
echo foo 2>/dev/null > "Name and an${HT}HT"
16 17 18
if ! test -f "Name and an${HT}HT"
then
	# FAT/NTFS does not allow tabs in filenames
19 20
	skip_all='Your filesystem does not allow tabs in filenames'
	test_done
21
fi
22

23 24 25 26
for_each_name () {
	for name in \
	    Name "Name and a${LF}LF" "Name and an${HT}HT" "Name${DQ}" \
	    "$FN$HT$GN" "$FN$LF$GN" "$FN $GN" "$FN$GN" "$FN$DQ$GN" \
27
	    "With SP in it" "$FN/file"
28 29 30 31 32
	do
		eval "$1"
	done
}

33
test_expect_success 'setup' '
34

35
	mkdir "$FN" &&
Jonathan Nieder's avatar
Jonathan Nieder committed
36
	for_each_name "echo initial >\"\$name\"" &&
37 38 39 40
	git add . &&
	git commit -q -m Initial &&

	for_each_name "echo second >\"\$name\"" &&
Jonathan Nieder's avatar
Jonathan Nieder committed
41
	git commit -a -m Second &&
42 43 44 45 46

	for_each_name "echo modified >\"\$name\""

'

47
test_expect_success 'setup expected files' '
Jonathan Nieder's avatar
Jonathan Nieder committed
48
cat >expect.quoted <<\EOF &&
49 50 51 52 53 54 55 56 57
Name
"Name and a\nLF"
"Name and an\tHT"
"Name\""
With SP in it
"\346\277\261\351\207\216\t\347\264\224"
"\346\277\261\351\207\216\n\347\264\224"
"\346\277\261\351\207\216 \347\264\224"
"\346\277\261\351\207\216\"\347\264\224"
58
"\346\277\261\351\207\216/file"
59 60 61 62 63 64 65 66 67 68 69 70 71
"\346\277\261\351\207\216\347\264\224"
EOF

cat >expect.raw <<\EOF
Name
"Name and a\nLF"
"Name and an\tHT"
"Name\""
With SP in it
"濱野\t純"
"濱野\n純"
濱野 純
"濱野\"純"
72
濱野/file
73 74
濱野純
EOF
75
'
76

77
test_expect_success 'check fully quoted output from ls-files' '
78

79
	git ls-files >current && test_cmp expect.quoted current
80 81 82

'

83
test_expect_success 'check fully quoted output from diff-files' '
84 85

	git diff --name-only >current &&
86
	test_cmp expect.quoted current
87 88 89

'

90
test_expect_success 'check fully quoted output from diff-index' '
91 92

	git diff --name-only HEAD >current &&
93
	test_cmp expect.quoted current
94 95 96

'

97
test_expect_success 'check fully quoted output from diff-tree' '
98 99

	git diff --name-only HEAD^ HEAD >current &&
100
	test_cmp expect.quoted current
101 102 103

'

104
test_expect_success 'check fully quoted output from ls-tree' '
105 106 107 108 109 110

	git ls-tree --name-only -r HEAD >current &&
	test_cmp expect.quoted current

'

111
test_expect_success 'setting core.quotepath' '
112 113 114 115 116

	git config --bool core.quotepath false

'

117
test_expect_success 'check fully quoted output from ls-files' '
118

119
	git ls-files >current && test_cmp expect.raw current
120 121 122

'

123
test_expect_success 'check fully quoted output from diff-files' '
124 125

	git diff --name-only >current &&
126
	test_cmp expect.raw current
127 128 129

'

130
test_expect_success 'check fully quoted output from diff-index' '
131 132

	git diff --name-only HEAD >current &&
133
	test_cmp expect.raw current
134 135 136

'

137
test_expect_success 'check fully quoted output from diff-tree' '
138 139

	git diff --name-only HEAD^ HEAD >current &&
140
	test_cmp expect.raw current
141 142 143

'

144
test_expect_success 'check fully quoted output from ls-tree' '
145 146 147 148 149 150

	git ls-tree --name-only -r HEAD >current &&
	test_cmp expect.raw current

'

151
test_done