]> git.ipfire.org Git - thirdparty/git.git/blame - t/t3300-funny-names.sh
git-status: use ls-files --others --directory for untracked list.
[thirdparty/git.git] / t / t3300-funny-names.sh
CommitLineData
4d2060ef
JH
1#!/bin/sh
2#
3# Copyright (c) 2005 Junio C Hamano
4#
5
6test_description='Pathnames with funny characters.
7
8This test tries pathnames with funny characters in the working
9tree, index, and tree objects.
10'
11
12. ./test-lib.sh
13
14p0='no-funny'
73ab46d6 15p1='tabs ," (dq) and spaces'
508c1d1c 16p2='just space'
4d2060ef
JH
17
18cat >"$p0" <<\EOF
191. A quick brown fox jumps over the lazy cat, oops dog.
202. A quick brown fox jumps over the lazy cat, oops dog.
213. A quick brown fox jumps over the lazy cat, oops dog.
22EOF
23
24cat >"$p1" "$p0"
508c1d1c 25echo 'Foo Bar Baz' >"$p2"
4d2060ef 26
6ce18321
JH
27test -f "$p1" && cmp "$p0" "$p1" || {
28 # since FAT/NTFS does not allow tabs in filenames, skip this test
29 say 'Your filesystem does not allow tabs in filenames, test skipped.'
30 test_done
31}
32
508c1d1c
JH
33echo 'just space
34no-funny' >expected
4d2060ef 35test_expect_success 'git-ls-files no-funny' \
508c1d1c 36 'git-update-index --add "$p0" "$p2" &&
4d2060ef
JH
37 git-ls-files >current &&
38 diff -u expected current'
39
40t0=`git-write-tree`
41echo "$t0" >t0
42
508c1d1c
JH
43echo 'just space
44no-funny
73ab46d6 45"tabs\t,\" (dq) and spaces"' >expected
4d2060ef
JH
46test_expect_success 'git-ls-files with-funny' \
47 'git-update-index --add "$p1" &&
48 git-ls-files >current &&
49 diff -u expected current'
50
508c1d1c
JH
51echo 'just space
52no-funny
73ab46d6 53tabs ," (dq) and spaces' >expected
4d2060ef
JH
54test_expect_success 'git-ls-files -z with-funny' \
55 'git-ls-files -z | tr \\0 \\012 >current &&
56 diff -u expected current'
57
58t1=`git-write-tree`
59echo "$t1" >t1
60
508c1d1c
JH
61echo 'just space
62no-funny
73ab46d6 63"tabs\t,\" (dq) and spaces"' >expected
4d2060ef
JH
64test_expect_success 'git-ls-tree with funny' \
65 'git-ls-tree -r $t1 | sed -e "s/^[^ ]* //" >current &&
66 diff -u expected current'
67
73ab46d6 68echo 'A "tabs\t,\" (dq) and spaces"' >expected
4d2060ef
JH
69test_expect_success 'git-diff-index with-funny' \
70 'git-diff-index --name-status $t0 >current &&
71 diff -u expected current'
72
73test_expect_success 'git-diff-tree with-funny' \
74 'git-diff-tree --name-status $t0 $t1 >current &&
75 diff -u expected current'
76
77echo 'A
73ab46d6 78tabs ," (dq) and spaces' >expected
4d2060ef
JH
79test_expect_success 'git-diff-index -z with-funny' \
80 'git-diff-index -z --name-status $t0 | tr \\0 \\012 >current &&
81 diff -u expected current'
82
83test_expect_success 'git-diff-tree -z with-funny' \
84 'git-diff-tree -z --name-status $t0 $t1 | tr \\0 \\012 >current &&
85 diff -u expected current'
86
73ab46d6 87echo 'CNUM no-funny "tabs\t,\" (dq) and spaces"' >expected
4d2060ef
JH
88test_expect_success 'git-diff-tree -C with-funny' \
89 'git-diff-tree -C --find-copies-harder --name-status \
90 $t0 $t1 | sed -e 's/^C[0-9]*/CNUM/' >current &&
91 diff -u expected current'
92
73ab46d6 93echo 'RNUM no-funny "tabs\t,\" (dq) and spaces"' >expected
4d2060ef
JH
94test_expect_success 'git-diff-tree delete with-funny' \
95 'git-update-index --force-remove "$p0" &&
96 git-diff-index -M --name-status \
97 $t0 | sed -e 's/^R[0-9]*/RNUM/' >current &&
98 diff -u expected current'
99
73ab46d6 100echo 'diff --git a/no-funny "b/tabs\t,\" (dq) and spaces"
4d2060ef
JH
101similarity index NUM%
102rename from no-funny
73ab46d6 103rename to "tabs\t,\" (dq) and spaces"' >expected
4d2060ef
JH
104
105test_expect_success 'git-diff-tree delete with-funny' \
106 'git-diff-index -M -p $t0 |
107 sed -e "s/index [0-9]*%/index NUM%/" >current &&
108 diff -u expected current'
109
110chmod +x "$p1"
73ab46d6 111echo 'diff --git a/no-funny "b/tabs\t,\" (dq) and spaces"
4d2060ef
JH
112old mode 100644
113new mode 100755
114similarity index NUM%
115rename from no-funny
73ab46d6 116rename to "tabs\t,\" (dq) and spaces"' >expected
4d2060ef
JH
117
118test_expect_success 'git-diff-tree delete with-funny' \
119 'git-diff-index -M -p $t0 |
120 sed -e "s/index [0-9]*%/index NUM%/" >current &&
121 diff -u expected current'
122
73ab46d6 123echo >expected ' "tabs\t,\" (dq) and spaces"
4d2060ef
JH
124 1 files changed, 0 insertions(+), 0 deletions(-)'
125test_expect_success 'git-diff-tree rename with-funny applied' \
126 'git-diff-index -M -p $t0 |
127 git-apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
128 diff -u expected current'
129
130echo >expected ' no-funny
73ab46d6 131 "tabs\t,\" (dq) and spaces"
4d2060ef
JH
132 2 files changed, 3 insertions(+), 3 deletions(-)'
133
134test_expect_success 'git-diff-tree delete with-funny applied' \
135 'git-diff-index -p $t0 |
136 git-apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
137 diff -u expected current'
138
139test_expect_success 'git-apply non-git diff' \
140 'git-diff-index -p $t0 |
141 sed -ne "/^[-+@]/p" |
142 git-apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
143 diff -u expected current'
144
145test_done