Make "git help" react to window size correctly
[git.git] / t / t3300-funny-names.sh
blob6a85d67c57e4fc6b8ae569b8410c03830af8a231
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 # since FAT/NTFS does not allow tabs in filenames, skip this test
13 test "$(uname -o 2>/dev/null)" = Cygwin && exit 0
15 . ./test-lib.sh
17 p0='no-funny'
18 p1='tabs ," (dq) and spaces'
19 p2='just space'
21 cat >"$p0" <<\EOF
22 1. A quick brown fox jumps over the lazy cat, oops dog.
23 2. A quick brown fox jumps over the lazy cat, oops dog.
24 3. A quick brown fox jumps over the lazy cat, oops dog.
25 EOF
27 cat >"$p1" "$p0"
28 echo 'Foo Bar Baz' >"$p2"
30 echo 'just space
31 no-funny' >expected
32 test_expect_success 'git-ls-files no-funny' \
33 'git-update-index --add "$p0" "$p2" &&
34 git-ls-files >current &&
35 diff -u expected current'
37 t0=`git-write-tree`
38 echo "$t0" >t0
40 echo 'just space
41 no-funny
42 "tabs\t,\" (dq) and spaces"' >expected
43 test_expect_success 'git-ls-files with-funny' \
44 'git-update-index --add "$p1" &&
45 git-ls-files >current &&
46 diff -u expected current'
48 echo 'just space
49 no-funny
50 tabs ," (dq) and spaces' >expected
51 test_expect_success 'git-ls-files -z with-funny' \
52 'git-ls-files -z | tr \\0 \\012 >current &&
53 diff -u expected current'
55 t1=`git-write-tree`
56 echo "$t1" >t1
58 echo 'just space
59 no-funny
60 "tabs\t,\" (dq) and spaces"' >expected
61 test_expect_success 'git-ls-tree with funny' \
62 'git-ls-tree -r $t1 | sed -e "s/^[^ ]* //" >current &&
63 diff -u expected current'
65 echo 'A "tabs\t,\" (dq) and spaces"' >expected
66 test_expect_success 'git-diff-index with-funny' \
67 'git-diff-index --name-status $t0 >current &&
68 diff -u expected current'
70 test_expect_success 'git-diff-tree with-funny' \
71 'git-diff-tree --name-status $t0 $t1 >current &&
72 diff -u expected current'
74 echo 'A
75 tabs ," (dq) and spaces' >expected
76 test_expect_success 'git-diff-index -z with-funny' \
77 'git-diff-index -z --name-status $t0 | tr \\0 \\012 >current &&
78 diff -u expected current'
80 test_expect_success 'git-diff-tree -z with-funny' \
81 'git-diff-tree -z --name-status $t0 $t1 | tr \\0 \\012 >current &&
82 diff -u expected current'
84 echo 'CNUM no-funny "tabs\t,\" (dq) and spaces"' >expected
85 test_expect_success 'git-diff-tree -C with-funny' \
86 'git-diff-tree -C --find-copies-harder --name-status \
87 $t0 $t1 | sed -e 's/^C[0-9]*/CNUM/' >current &&
88 diff -u expected current'
90 echo 'RNUM no-funny "tabs\t,\" (dq) and spaces"' >expected
91 test_expect_success 'git-diff-tree delete with-funny' \
92 'git-update-index --force-remove "$p0" &&
93 git-diff-index -M --name-status \
94 $t0 | sed -e 's/^R[0-9]*/RNUM/' >current &&
95 diff -u expected current'
97 echo 'diff --git a/no-funny "b/tabs\t,\" (dq) and spaces"
98 similarity index NUM%
99 rename from no-funny
100 rename to "tabs\t,\" (dq) and spaces"' >expected
102 test_expect_success 'git-diff-tree delete with-funny' \
103 'git-diff-index -M -p $t0 |
104 sed -e "s/index [0-9]*%/index NUM%/" >current &&
105 diff -u expected current'
107 chmod +x "$p1"
108 echo 'diff --git a/no-funny "b/tabs\t,\" (dq) and spaces"
109 old mode 100644
110 new mode 100755
111 similarity index NUM%
112 rename from no-funny
113 rename to "tabs\t,\" (dq) and spaces"' >expected
115 test_expect_success 'git-diff-tree delete with-funny' \
116 'git-diff-index -M -p $t0 |
117 sed -e "s/index [0-9]*%/index NUM%/" >current &&
118 diff -u expected current'
120 echo >expected ' "tabs\t,\" (dq) and spaces"
121 1 files changed, 0 insertions(+), 0 deletions(-)'
122 test_expect_success 'git-diff-tree rename with-funny applied' \
123 'git-diff-index -M -p $t0 |
124 git-apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
125 diff -u expected current'
127 echo >expected ' no-funny
128 "tabs\t,\" (dq) and spaces"
129 2 files changed, 3 insertions(+), 3 deletions(-)'
131 test_expect_success 'git-diff-tree delete with-funny applied' \
132 'git-diff-index -p $t0 |
133 git-apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
134 diff -u expected current'
136 test_expect_success 'git-apply non-git diff' \
137 'git-diff-index -p $t0 |
138 sed -ne "/^[-+@]/p" |
139 git-apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
140 diff -u expected current'
142 test_done