blob: f528008c363c68f40da3b88a34ae8ec931d0c1ac [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
Johannes Schindelin4539a892016-01-27 17:20:26 +010015test_have_prereq MINGW ||
Ramsay Jones2b843732008-08-26 18:52:57 +010016echo foo 2>/dev/null > "Name and an${HT}HT"
Ævar Arnfjörð Bjarmasona0beb132010-08-11 19:04:09 +000017if ! test -f "Name and an${HT}HT"
18then
19 # FAT/NTFS does not allow tabs in filenames
Ramsay Jonesbb8eb642012-09-01 19:10:01 +010020 skip_all='Your filesystem does not allow tabs in filenames'
21 test_done
Ævar Arnfjörð Bjarmasona0beb132010-08-11 19:04:09 +000022fi
Johannes Sixt25482a32007-11-13 21:04:59 +010023
Junio C Hamano9378c162007-06-24 15:11:24 -070024for_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" \
Brian Gernhardt8b2337a2010-02-08 23:07:25 -050028 "With SP in it" "$FN/file"
Junio C Hamano9378c162007-06-24 15:11:24 -070029 do
30 eval "$1"
31 done
32}
33
Ramsay Jonesbb8eb642012-09-01 19:10:01 +010034test_expect_success 'setup' '
Junio C Hamano9378c162007-06-24 15:11:24 -070035
Brian Gernhardt8b2337a2010-02-08 23:07:25 -050036 mkdir "$FN" &&
Jonathan Niedera48fcd82010-10-30 20:46:54 -050037 for_each_name "echo initial >\"\$name\"" &&
Junio C Hamano9378c162007-06-24 15:11:24 -070038 git add . &&
39 git commit -q -m Initial &&
40
41 for_each_name "echo second >\"\$name\"" &&
Jonathan Niedera48fcd82010-10-30 20:46:54 -050042 git commit -a -m Second &&
Junio C Hamano9378c162007-06-24 15:11:24 -070043
44 for_each_name "echo modified >\"\$name\""
45
46'
47
Ramsay Jonesbb8eb642012-09-01 19:10:01 +010048test_expect_success 'setup expected files' '
Jonathan Niedera48fcd82010-10-30 20:46:54 -050049cat >expect.quoted <<\EOF &&
Junio C Hamano9378c162007-06-24 15:11:24 -070050Name
51"Name and a\nLF"
52"Name and an\tHT"
53"Name\""
54With SP in it
55"\346\277\261\351\207\216\t\347\264\224"
56"\346\277\261\351\207\216\n\347\264\224"
57"\346\277\261\351\207\216 \347\264\224"
58"\346\277\261\351\207\216\"\347\264\224"
Brian Gernhardt8b2337a2010-02-08 23:07:25 -050059"\346\277\261\351\207\216/file"
Junio C Hamano9378c162007-06-24 15:11:24 -070060"\346\277\261\351\207\216\347\264\224"
61EOF
62
63cat >expect.raw <<\EOF
64Name
65"Name and a\nLF"
66"Name and an\tHT"
67"Name\""
68With SP in it
69"濱野\t純"
70"濱野\n純"
71濱野 純
72"濱野\"純"
Brian Gernhardt8b2337a2010-02-08 23:07:25 -050073濱野/file
Junio C Hamano9378c162007-06-24 15:11:24 -070074濱野純
75EOF
Ævar Arnfjörð Bjarmasona0beb132010-08-11 19:04:09 +000076'
Junio C Hamano9378c162007-06-24 15:11:24 -070077
Ramsay Jonesbb8eb642012-09-01 19:10:01 +010078test_expect_success 'check fully quoted output from ls-files' '
Junio C Hamano9378c162007-06-24 15:11:24 -070079
Jeff King82ebb0b2008-03-12 17:36:36 -040080 git ls-files >current && test_cmp expect.quoted current
Junio C Hamano9378c162007-06-24 15:11:24 -070081
82'
83
Ramsay Jonesbb8eb642012-09-01 19:10:01 +010084test_expect_success 'check fully quoted output from diff-files' '
Junio C Hamano9378c162007-06-24 15:11:24 -070085
86 git diff --name-only >current &&
Jeff King82ebb0b2008-03-12 17:36:36 -040087 test_cmp expect.quoted current
Junio C Hamano9378c162007-06-24 15:11:24 -070088
89'
90
Ramsay Jonesbb8eb642012-09-01 19:10:01 +010091test_expect_success 'check fully quoted output from diff-index' '
Junio C Hamano9378c162007-06-24 15:11:24 -070092
93 git diff --name-only HEAD >current &&
Jeff King82ebb0b2008-03-12 17:36:36 -040094 test_cmp expect.quoted current
Junio C Hamano9378c162007-06-24 15:11:24 -070095
96'
97
Ramsay Jonesbb8eb642012-09-01 19:10:01 +010098test_expect_success 'check fully quoted output from diff-tree' '
Junio C Hamano9378c162007-06-24 15:11:24 -070099
100 git diff --name-only HEAD^ HEAD >current &&
Jeff King82ebb0b2008-03-12 17:36:36 -0400101 test_cmp expect.quoted current
Junio C Hamano9378c162007-06-24 15:11:24 -0700102
103'
104
Ramsay Jonesbb8eb642012-09-01 19:10:01 +0100105test_expect_success 'check fully quoted output from ls-tree' '
Jeff King84249812010-02-01 08:39:03 -0500106
107 git ls-tree --name-only -r HEAD >current &&
108 test_cmp expect.quoted current
109
110'
111
Ramsay Jonesbb8eb642012-09-01 19:10:01 +0100112test_expect_success 'setting core.quotepath' '
Junio C Hamano9378c162007-06-24 15:11:24 -0700113
114 git config --bool core.quotepath false
115
116'
117
Ramsay Jonesbb8eb642012-09-01 19:10:01 +0100118test_expect_success 'check fully quoted output from ls-files' '
Junio C Hamano9378c162007-06-24 15:11:24 -0700119
Jeff King82ebb0b2008-03-12 17:36:36 -0400120 git ls-files >current && test_cmp expect.raw current
Junio C Hamano9378c162007-06-24 15:11:24 -0700121
122'
123
Ramsay Jonesbb8eb642012-09-01 19:10:01 +0100124test_expect_success 'check fully quoted output from diff-files' '
Junio C Hamano9378c162007-06-24 15:11:24 -0700125
126 git diff --name-only >current &&
Jeff King82ebb0b2008-03-12 17:36:36 -0400127 test_cmp expect.raw current
Junio C Hamano9378c162007-06-24 15:11:24 -0700128
129'
130
Ramsay Jonesbb8eb642012-09-01 19:10:01 +0100131test_expect_success 'check fully quoted output from diff-index' '
Junio C Hamano9378c162007-06-24 15:11:24 -0700132
133 git diff --name-only HEAD >current &&
Jeff King82ebb0b2008-03-12 17:36:36 -0400134 test_cmp expect.raw current
Junio C Hamano9378c162007-06-24 15:11:24 -0700135
136'
137
Ramsay Jonesbb8eb642012-09-01 19:10:01 +0100138test_expect_success 'check fully quoted output from diff-tree' '
Junio C Hamano9378c162007-06-24 15:11:24 -0700139
140 git diff --name-only HEAD^ HEAD >current &&
Jeff King82ebb0b2008-03-12 17:36:36 -0400141 test_cmp expect.raw current
Junio C Hamano9378c162007-06-24 15:11:24 -0700142
143'
144
Ramsay Jonesbb8eb642012-09-01 19:10:01 +0100145test_expect_success 'check fully quoted output from ls-tree' '
Jeff King84249812010-02-01 08:39:03 -0500146
147 git ls-tree --name-only -r HEAD >current &&
148 test_cmp expect.raw current
149
150'
151
Junio C Hamano9378c162007-06-24 15:11:24 -0700152test_done