man pages are littered with .ft C and others
[git/git-p4.git] / t / t3902-quoted.sh
blob73da45f18c2c5a58828c56c561e27012aa901a9a
1 #!/bin/sh
3 # Copyright (c) 2006 Junio C Hamano
6 test_description='quoted output'
8 . ./test-lib.sh
10 P1='pathname with HT'
11 : >"$P1" 2>&1 && test -f "$P1" && rm -f "$P1" || {
12 echo >&2 'Filesystem does not support HT in names'
13 test_done
16 FN='濱野'
17 GN='純'
18 HT=' '
19 LF='
21 DQ='"'
23 echo foo > "Name and an${HT}HT"
24 test -f "Name and an${HT}HT" || {
25 # since FAT/NTFS does not allow tabs in filenames, skip this test
26 say 'Your filesystem does not allow tabs in filenames, test skipped.'
27 test_done
30 for_each_name () {
31 for name in \
32 Name "Name and a${LF}LF" "Name and an${HT}HT" "Name${DQ}" \
33 "$FN$HT$GN" "$FN$LF$GN" "$FN $GN" "$FN$GN" "$FN$DQ$GN" \
34 "With SP in it"
36 eval "$1"
37 done
40 test_expect_success setup '
42 for_each_name "echo initial >\"\$name\""
43 git add . &&
44 git commit -q -m Initial &&
46 for_each_name "echo second >\"\$name\"" &&
47 git commit -a -m Second
49 for_each_name "echo modified >\"\$name\""
53 cat >expect.quoted <<\EOF
54 Name
55 "Name and a\nLF"
56 "Name and an\tHT"
57 "Name\""
58 With SP in it
59 "\346\277\261\351\207\216\t\347\264\224"
60 "\346\277\261\351\207\216\n\347\264\224"
61 "\346\277\261\351\207\216 \347\264\224"
62 "\346\277\261\351\207\216\"\347\264\224"
63 "\346\277\261\351\207\216\347\264\224"
64 EOF
66 cat >expect.raw <<\EOF
67 Name
68 "Name and a\nLF"
69 "Name and an\tHT"
70 "Name\""
71 With SP in it
72 "濱野\t純"
73 "濱野\n純"
74 濱野 純
75 "濱野\"純"
76 濱野純
77 EOF
79 test_expect_success 'check fully quoted output from ls-files' '
81 git ls-files >current && diff -u expect.quoted current
85 test_expect_success 'check fully quoted output from diff-files' '
87 git diff --name-only >current &&
88 diff -u expect.quoted current
92 test_expect_success 'check fully quoted output from diff-index' '
94 git diff --name-only HEAD >current &&
95 diff -u expect.quoted current
99 test_expect_success 'check fully quoted output from diff-tree' '
101 git diff --name-only HEAD^ HEAD >current &&
102 diff -u expect.quoted current
106 test_expect_success 'setting core.quotepath' '
108 git config --bool core.quotepath false
112 test_expect_success 'check fully quoted output from ls-files' '
114 git ls-files >current && diff -u expect.raw current
118 test_expect_success 'check fully quoted output from diff-files' '
120 git diff --name-only >current &&
121 diff -u expect.raw current
125 test_expect_success 'check fully quoted output from diff-index' '
127 git diff --name-only HEAD >current &&
128 diff -u expect.raw current
132 test_expect_success 'check fully quoted output from diff-tree' '
134 git diff --name-only HEAD^ HEAD >current &&
135 diff -u expect.raw current
139 test_done