blob: 892f5678441b3c9065f743d9fe9f071334420831 [file] [log] [blame]
Junio C Hamano9378c162007-06-24 15:11:24 -07001#!/bin/sh
2#
3# Copyright (c) 2006 Junio C Hamano
4#
5
6test_description='quoted output'
7
8. ./test-lib.sh
9
Junio C Hamano9378c162007-06-24 15:11:24 -070010FN='濱野'
11GN='純'
12HT=' '
Junio C Hamano9378c162007-06-24 15:11:24 -070013DQ='"'
14
Ramsay Jones2b843732008-08-26 18:52:57 +010015echo foo 2>/dev/null > "Name and an${HT}HT"
Ævar Arnfjörð Bjarmasona0beb132010-08-11 19:04:09 +000016if ! test -f "Name and an${HT}HT"
17then
18 # FAT/NTFS does not allow tabs in filenames
Ramsay Jonesbb8eb642012-09-01 19:10:01 +010019 skip_all='Your filesystem does not allow tabs in filenames'
20 test_done
Ævar Arnfjörð Bjarmasona0beb132010-08-11 19:04:09 +000021fi
Johannes Sixt25482a32007-11-13 21:04:59 +010022
Junio C Hamano9378c162007-06-24 15:11:24 -070023for_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" \
Brian Gernhardt8b2337a2010-02-08 23:07:25 -050027 "With SP in it" "$FN/file"
Junio C Hamano9378c162007-06-24 15:11:24 -070028 do
29 eval "$1"
30 done
31}
32
Ramsay Jonesbb8eb642012-09-01 19:10:01 +010033test_expect_success 'setup' '
Junio C Hamano9378c162007-06-24 15:11:24 -070034
Brian Gernhardt8b2337a2010-02-08 23:07:25 -050035 mkdir "$FN" &&
Jonathan Niedera48fcd82010-10-30 20:46:54 -050036 for_each_name "echo initial >\"\$name\"" &&
Junio C Hamano9378c162007-06-24 15:11:24 -070037 git add . &&
38 git commit -q -m Initial &&
39
40 for_each_name "echo second >\"\$name\"" &&
Jonathan Niedera48fcd82010-10-30 20:46:54 -050041 git commit -a -m Second &&
Junio C Hamano9378c162007-06-24 15:11:24 -070042
43 for_each_name "echo modified >\"\$name\""
44
45'
46
Ramsay Jonesbb8eb642012-09-01 19:10:01 +010047test_expect_success 'setup expected files' '
Jonathan Niedera48fcd82010-10-30 20:46:54 -050048cat >expect.quoted <<\EOF &&
Junio C Hamano9378c162007-06-24 15:11:24 -070049Name
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"
Brian Gernhardt8b2337a2010-02-08 23:07:25 -050058"\346\277\261\351\207\216/file"
Junio C Hamano9378c162007-06-24 15:11:24 -070059"\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"濱野\"純"
Brian Gernhardt8b2337a2010-02-08 23:07:25 -050072濱野/file
Junio C Hamano9378c162007-06-24 15:11:24 -070073濱野純
74EOF
Ævar Arnfjörð Bjarmasona0beb132010-08-11 19:04:09 +000075'
Junio C Hamano9378c162007-06-24 15:11:24 -070076
Ramsay Jonesbb8eb642012-09-01 19:10:01 +010077test_expect_success 'check fully quoted output from ls-files' '
Junio C Hamano9378c162007-06-24 15:11:24 -070078
Jeff King82ebb0b2008-03-12 17:36:36 -040079 git ls-files >current && test_cmp expect.quoted current
Junio C Hamano9378c162007-06-24 15:11:24 -070080
81'
82
Ramsay Jonesbb8eb642012-09-01 19:10:01 +010083test_expect_success 'check fully quoted output from diff-files' '
Junio C Hamano9378c162007-06-24 15:11:24 -070084
85 git diff --name-only >current &&
Jeff King82ebb0b2008-03-12 17:36:36 -040086 test_cmp expect.quoted current
Junio C Hamano9378c162007-06-24 15:11:24 -070087
88'
89
Ramsay Jonesbb8eb642012-09-01 19:10:01 +010090test_expect_success 'check fully quoted output from diff-index' '
Junio C Hamano9378c162007-06-24 15:11:24 -070091
92 git diff --name-only HEAD >current &&
Jeff King82ebb0b2008-03-12 17:36:36 -040093 test_cmp expect.quoted current
Junio C Hamano9378c162007-06-24 15:11:24 -070094
95'
96
Ramsay Jonesbb8eb642012-09-01 19:10:01 +010097test_expect_success 'check fully quoted output from diff-tree' '
Junio C Hamano9378c162007-06-24 15:11:24 -070098
99 git diff --name-only HEAD^ HEAD >current &&
Jeff King82ebb0b2008-03-12 17:36:36 -0400100 test_cmp expect.quoted current
Junio C Hamano9378c162007-06-24 15:11:24 -0700101
102'
103
Ramsay Jonesbb8eb642012-09-01 19:10:01 +0100104test_expect_success 'check fully quoted output from ls-tree' '
Jeff King84249812010-02-01 08:39:03 -0500105
106 git ls-tree --name-only -r HEAD >current &&
107 test_cmp expect.quoted current
108
109'
110
Ramsay Jonesbb8eb642012-09-01 19:10:01 +0100111test_expect_success 'setting core.quotepath' '
Junio C Hamano9378c162007-06-24 15:11:24 -0700112
113 git config --bool core.quotepath false
114
115'
116
Ramsay Jonesbb8eb642012-09-01 19:10:01 +0100117test_expect_success 'check fully quoted output from ls-files' '
Junio C Hamano9378c162007-06-24 15:11:24 -0700118
Jeff King82ebb0b2008-03-12 17:36:36 -0400119 git ls-files >current && test_cmp expect.raw current
Junio C Hamano9378c162007-06-24 15:11:24 -0700120
121'
122
Ramsay Jonesbb8eb642012-09-01 19:10:01 +0100123test_expect_success 'check fully quoted output from diff-files' '
Junio C Hamano9378c162007-06-24 15:11:24 -0700124
125 git diff --name-only >current &&
Jeff King82ebb0b2008-03-12 17:36:36 -0400126 test_cmp expect.raw current
Junio C Hamano9378c162007-06-24 15:11:24 -0700127
128'
129
Ramsay Jonesbb8eb642012-09-01 19:10:01 +0100130test_expect_success 'check fully quoted output from diff-index' '
Junio C Hamano9378c162007-06-24 15:11:24 -0700131
132 git diff --name-only HEAD >current &&
Jeff King82ebb0b2008-03-12 17:36:36 -0400133 test_cmp expect.raw current
Junio C Hamano9378c162007-06-24 15:11:24 -0700134
135'
136
Ramsay Jonesbb8eb642012-09-01 19:10:01 +0100137test_expect_success 'check fully quoted output from diff-tree' '
Junio C Hamano9378c162007-06-24 15:11:24 -0700138
139 git diff --name-only HEAD^ HEAD >current &&
Jeff King82ebb0b2008-03-12 17:36:36 -0400140 test_cmp expect.raw current
Junio C Hamano9378c162007-06-24 15:11:24 -0700141
142'
143
Ramsay Jonesbb8eb642012-09-01 19:10:01 +0100144test_expect_success 'check fully quoted output from ls-tree' '
Jeff King84249812010-02-01 08:39:03 -0500145
146 git ls-tree --name-only -r HEAD >current &&
147 test_cmp expect.raw current
148
149'
150
Junio C Hamano9378c162007-06-24 15:11:24 -0700151test_done