Add tests for funny pathnames.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Oct 15, 2005 at 16:15 UTC
4d2060efebe855e49365c7be117b80c1e486a6b4
1 file changed
+133
t/t3300-funny-names.sh
new
+133
@@ -0,0 +1,133 @@
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 and spaces'
16
+
17
+cat >"$p0" <<\EOF
18
+1. A quick brown fox jumps over the lazy cat, oops dog.
19
+2. A quick brown fox jumps over the lazy cat, oops dog.
20
+3. A quick brown fox jumps over the lazy cat, oops dog.
21
+EOF
22
+
23
+cat >"$p1" "$p0"
24
+
25
+echo 'no-funny' >expected
26
+test_expect_success 'git-ls-files no-funny' \
27
+ 'git-update-index --add "$p0" &&
28
+ git-ls-files >current &&
29
+ diff -u expected current'
30
+
31
+t0=`git-write-tree`
32
+echo "$t0" >t0
33
+
34
+echo 'no-funny
35
+"tabs\tand spaces"' >expected
36
+test_expect_success 'git-ls-files with-funny' \
37
+ 'git-update-index --add "$p1" &&
38
+ git-ls-files >current &&
39
+ diff -u expected current'
40
+
41
+echo 'no-funny
42
+tabs and spaces' >expected
43
+test_expect_success 'git-ls-files -z with-funny' \
44
+ 'git-ls-files -z | tr \\0 \\012 >current &&
45
+ diff -u expected current'
46
+
47
+t1=`git-write-tree`
48
+echo "$t1" >t1
49
+
50
+echo 'no-funny
51
+"tabs\tand spaces"' >expected
52
+test_expect_success 'git-ls-tree with funny' \
53
+ 'git-ls-tree -r $t1 | sed -e "s/^[^ ]* //" >current &&
54
+ diff -u expected current'
55
+
56
+echo 'A "tabs\tand spaces"' >expected
57
+test_expect_success 'git-diff-index with-funny' \
58
+ 'git-diff-index --name-status $t0 >current &&
59
+ diff -u expected current'
60
+
61
+test_expect_success 'git-diff-tree with-funny' \
62
+ 'git-diff-tree --name-status $t0 $t1 >current &&
63
+ diff -u expected current'
64
+
65
+echo 'A
66
+tabs and spaces' >expected
67
+test_expect_success 'git-diff-index -z with-funny' \
68
+ 'git-diff-index -z --name-status $t0 | tr \\0 \\012 >current &&
69
+ diff -u expected current'
70
+
71
+test_expect_success 'git-diff-tree -z with-funny' \
72
+ 'git-diff-tree -z --name-status $t0 $t1 | tr \\0 \\012 >current &&
73
+ diff -u expected current'
74
+
75
+echo 'CNUM no-funny "tabs\tand spaces"' >expected
76
+test_expect_success 'git-diff-tree -C with-funny' \
77
+ 'git-diff-tree -C --find-copies-harder --name-status \
78
+ $t0 $t1 | sed -e 's/^C[0-9]*/CNUM/' >current &&
79
+ diff -u expected current'
80
+
81
+echo 'RNUM no-funny "tabs\tand spaces"' >expected
82
+test_expect_success 'git-diff-tree delete with-funny' \
83
+ 'git-update-index --force-remove "$p0" &&
84
+ git-diff-index -M --name-status \
85
+ $t0 | sed -e 's/^R[0-9]*/RNUM/' >current &&
86
+ diff -u expected current'
87
+
88
+echo 'diff --git a/no-funny "b/tabs\tand spaces"
89
+similarity index NUM%
90
+rename from no-funny
91
+rename to "tabs\tand spaces"' >expected
92
+
93
+test_expect_success 'git-diff-tree delete with-funny' \
94
+ 'git-diff-index -M -p $t0 |
95
+ sed -e "s/index [0-9]*%/index NUM%/" >current &&
96
+ diff -u expected current'
97
+
98
+chmod +x "$p1"
99
+echo 'diff --git a/no-funny "b/tabs\tand spaces"
100
+old mode 100644
101
+new mode 100755
102
+similarity index NUM%
103
+rename from no-funny
104
+rename to "tabs\tand spaces"' >expected
105
+
106
+test_expect_success 'git-diff-tree delete with-funny' \
107
+ 'git-diff-index -M -p $t0 |
108
+ sed -e "s/index [0-9]*%/index NUM%/" >current &&
109
+ diff -u expected current'
110
+
111
+echo >expected ' "tabs\tand spaces"
112
+ 1 files changed, 0 insertions(+), 0 deletions(-)'
113
+test_expect_success 'git-diff-tree rename with-funny applied' \
114
+ 'git-diff-index -M -p $t0 |
115
+ git-apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
116
+ diff -u expected current'
117
+
118
+echo >expected ' no-funny
119
+ "tabs\tand spaces"
120
+ 2 files changed, 3 insertions(+), 3 deletions(-)'
121
+
122
+test_expect_success 'git-diff-tree delete with-funny applied' \
123
+ 'git-diff-index -p $t0 |
124
+ git-apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
125
+ diff -u expected current'
126
+
127
+test_expect_success 'git-apply non-git diff' \
128
+ 'git-diff-index -p $t0 |
129
+ sed -ne "/^[-+@]/p" |
130
+ git-apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
131
+ diff -u expected current'
132
+
133
+test_done