Merge branch 'jc/fsck'
[git/gitweb-caching.git] / t / t3300-funny-names.sh
blob72a93da08ca28857c6e2d2c16ace65db762698d5
1 #!/bin/sh
3 # Copyright (c) 2005 Junio C Hamano
6 test_description='Pathnames with funny characters.
8 This test tries pathnames with funny characters in the working
9 tree, index, and tree objects.
12 . ./test-lib.sh
14 p0='no-funny'
15 p1='tabs ," (dq) and spaces'
16 p2='just space'
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
24 cat >"$p1" "$p0"
25 echo 'Foo Bar Baz' >"$p2"
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
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'
40 t0=`git-write-tree`
41 echo "$t0" >t0
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'
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'
58 t1=`git-write-tree`
59 echo "$t1" >t1
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'
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'
73 test_expect_success 'git-diff-tree with-funny' \
74 'git-diff-tree --name-status $t0 $t1 >current &&
75 diff -u expected current'
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'
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'
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'
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'
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
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'
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
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'
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'
130 echo >expected ' no-funny
131 "tabs\t,\" (dq) and spaces"
132 2 files changed, 3 insertions(+), 3 deletions(-)'
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'
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'
145 test_done