fetch.c: do not call process_tree() from process_tree().
[git/git.git] / t / t3300-funny-names.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2005 Junio C Hamano
4 #
5
6 test_description='Pathnames with funny characters.
7
8 This test tries pathnames with funny characters in the working
9 tree, index, and tree objects.
10 '
11
12 . ./test-lib.sh
13
14 p0='no-funny'
15 p1='tabs ," (dq) and spaces'
16 p2='just space'
17
18 cat >"$p0" <<\EOF
19 1. A quick brown fox jumps over the lazy cat, oops dog.
20 2. A quick brown fox jumps over the lazy cat, oops dog.
21 3. A quick brown fox jumps over the lazy cat, oops dog.
22 EOF
23
24 cat >"$p1" "$p0"
25 echo 'Foo Bar Baz' >"$p2"
26
27 test -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
33 echo 'just space
34 no-funny' >expected
35 test_expect_success 'git-ls-files no-funny' \
36 'git-update-index --add "$p0" "$p2" &&
37 git-ls-files >current &&
38 diff -u expected current'
39
40 t0=`git-write-tree`
41 echo "$t0" >t0
42
43 echo 'just space
44 no-funny
45 "tabs\t,\" (dq) and spaces"' >expected
46 test_expect_success 'git-ls-files with-funny' \
47 'git-update-index --add "$p1" &&
48 git-ls-files >current &&
49 diff -u expected current'
50
51 echo 'just space
52 no-funny
53 tabs ," (dq) and spaces' >expected
54 test_expect_success 'git-ls-files -z with-funny' \
55 'git-ls-files -z | tr \\0 \\012 >current &&
56 diff -u expected current'
57
58 t1=`git-write-tree`
59 echo "$t1" >t1
60
61 echo 'just space
62 no-funny
63 "tabs\t,\" (dq) and spaces"' >expected
64 test_expect_success 'git-ls-tree with funny' \
65 'git-ls-tree -r $t1 | sed -e "s/^[^ ]* //" >current &&
66 diff -u expected current'
67
68 echo 'A "tabs\t,\" (dq) and spaces"' >expected
69 test_expect_success 'git-diff-index with-funny' \
70 'git-diff-index --name-status $t0 >current &&
71 diff -u expected current'
72
73 test_expect_success 'git-diff-tree with-funny' \
74 'git-diff-tree --name-status $t0 $t1 >current &&
75 diff -u expected current'
76
77 echo 'A
78 tabs ," (dq) and spaces' >expected
79 test_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
83 test_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
87 echo 'CNUM no-funny "tabs\t,\" (dq) and spaces"' >expected
88 test_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
93 echo 'RNUM no-funny "tabs\t,\" (dq) and spaces"' >expected
94 test_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
100 echo 'diff --git a/no-funny "b/tabs\t,\" (dq) and spaces"
101 similarity index NUM%
102 rename from no-funny
103 rename to "tabs\t,\" (dq) and spaces"' >expected
104
105 test_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
110 chmod +x "$p1"
111 echo 'diff --git a/no-funny "b/tabs\t,\" (dq) and spaces"
112 old mode 100644
113 new mode 100755
114 similarity index NUM%
115 rename from no-funny
116 rename to "tabs\t,\" (dq) and spaces"' >expected
117
118 test_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
123 echo >expected ' "tabs\t,\" (dq) and spaces"
124 1 files changed, 0 insertions(+), 0 deletions(-)'
125 test_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
130 echo >expected ' no-funny
131 "tabs\t,\" (dq) and spaces"
132 2 files changed, 3 insertions(+), 3 deletions(-)'
133
134 test_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
139 test_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
145 test_done