]>
Commit | Line | Data |
---|---|---|
4d2060ef JH |
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' | |
73ab46d6 | 15 | p1='tabs ," (dq) and spaces' |
508c1d1c | 16 | p2='just space' |
4d2060ef JH |
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 | ||
2b843732 | 24 | cat 2>/dev/null >"$p1" "$p0" |
508c1d1c | 25 | echo 'Foo Bar Baz' >"$p2" |
4d2060ef | 26 | |
6ce18321 JH |
27 | test -f "$p1" && cmp "$p0" "$p1" || { |
28 | # since FAT/NTFS does not allow tabs in filenames, skip this test | |
fadb5156 | 29 | skip_all='Your filesystem does not allow tabs in filenames, test skipped.' |
6ce18321 JH |
30 | test_done |
31 | } | |
32 | ||
508c1d1c JH |
33 | echo 'just space |
34 | no-funny' >expected | |
5be60078 JH |
35 | test_expect_success 'git ls-files no-funny' \ |
36 | 'git update-index --add "$p0" "$p2" && | |
37 | git ls-files >current && | |
3af82863 | 38 | test_cmp expected current' |
4d2060ef | 39 | |
5be60078 | 40 | t0=`git write-tree` |
4d2060ef JH |
41 | echo "$t0" >t0 |
42 | ||
003d6dda EW |
43 | cat > expected <<\EOF |
44 | just space | |
508c1d1c | 45 | no-funny |
003d6dda EW |
46 | "tabs\t,\" (dq) and spaces" |
47 | EOF | |
5be60078 JH |
48 | test_expect_success 'git ls-files with-funny' \ |
49 | 'git update-index --add "$p1" && | |
50 | git ls-files >current && | |
3af82863 | 51 | test_cmp expected current' |
4d2060ef | 52 | |
508c1d1c JH |
53 | echo 'just space |
54 | no-funny | |
73ab46d6 | 55 | tabs ," (dq) and spaces' >expected |
5be60078 | 56 | test_expect_success 'git ls-files -z with-funny' \ |
e85fe4d8 | 57 | 'git ls-files -z | perl -pe y/\\000/\\012/ >current && |
3af82863 | 58 | test_cmp expected current' |
4d2060ef | 59 | |
5be60078 | 60 | t1=`git write-tree` |
4d2060ef JH |
61 | echo "$t1" >t1 |
62 | ||
003d6dda EW |
63 | cat > expected <<\EOF |
64 | just space | |
508c1d1c | 65 | no-funny |
003d6dda EW |
66 | "tabs\t,\" (dq) and spaces" |
67 | EOF | |
5be60078 JH |
68 | test_expect_success 'git ls-tree with funny' \ |
69 | 'git ls-tree -r $t1 | sed -e "s/^[^ ]* //" >current && | |
3af82863 | 70 | test_cmp expected current' |
4d2060ef | 71 | |
003d6dda EW |
72 | cat > expected <<\EOF |
73 | A "tabs\t,\" (dq) and spaces" | |
74 | EOF | |
5be60078 JH |
75 | test_expect_success 'git diff-index with-funny' \ |
76 | 'git diff-index --name-status $t0 >current && | |
3af82863 | 77 | test_cmp expected current' |
4d2060ef | 78 | |
5be60078 JH |
79 | test_expect_success 'git diff-tree with-funny' \ |
80 | 'git diff-tree --name-status $t0 $t1 >current && | |
3af82863 | 81 | test_cmp expected current' |
4d2060ef JH |
82 | |
83 | echo 'A | |
73ab46d6 | 84 | tabs ," (dq) and spaces' >expected |
5be60078 | 85 | test_expect_success 'git diff-index -z with-funny' \ |
e85fe4d8 | 86 | 'git diff-index -z --name-status $t0 | perl -pe y/\\000/\\012/ >current && |
3af82863 | 87 | test_cmp expected current' |
4d2060ef | 88 | |
5be60078 | 89 | test_expect_success 'git diff-tree -z with-funny' \ |
e85fe4d8 | 90 | 'git diff-tree -z --name-status $t0 $t1 | perl -pe y/\\000/\\012/ >current && |
3af82863 | 91 | test_cmp expected current' |
4d2060ef | 92 | |
003d6dda EW |
93 | cat > expected <<\EOF |
94 | CNUM no-funny "tabs\t,\" (dq) and spaces" | |
95 | EOF | |
5be60078 JH |
96 | test_expect_success 'git diff-tree -C with-funny' \ |
97 | 'git diff-tree -C --find-copies-harder --name-status \ | |
4d2060ef | 98 | $t0 $t1 | sed -e 's/^C[0-9]*/CNUM/' >current && |
3af82863 | 99 | test_cmp expected current' |
4d2060ef | 100 | |
003d6dda EW |
101 | cat > expected <<\EOF |
102 | RNUM no-funny "tabs\t,\" (dq) and spaces" | |
103 | EOF | |
5be60078 JH |
104 | test_expect_success 'git diff-tree delete with-funny' \ |
105 | 'git update-index --force-remove "$p0" && | |
106 | git diff-index -M --name-status \ | |
4d2060ef | 107 | $t0 | sed -e 's/^R[0-9]*/RNUM/' >current && |
3af82863 | 108 | test_cmp expected current' |
4d2060ef | 109 | |
003d6dda EW |
110 | cat > expected <<\EOF |
111 | diff --git a/no-funny "b/tabs\t,\" (dq) and spaces" | |
4d2060ef JH |
112 | similarity index NUM% |
113 | rename from no-funny | |
003d6dda EW |
114 | rename to "tabs\t,\" (dq) and spaces" |
115 | EOF | |
5be60078 JH |
116 | test_expect_success 'git diff-tree delete with-funny' \ |
117 | 'git diff-index -M -p $t0 | | |
4d2060ef | 118 | sed -e "s/index [0-9]*%/index NUM%/" >current && |
3af82863 | 119 | test_cmp expected current' |
4d2060ef JH |
120 | |
121 | chmod +x "$p1" | |
003d6dda EW |
122 | cat > expected <<\EOF |
123 | diff --git a/no-funny "b/tabs\t,\" (dq) and spaces" | |
4d2060ef JH |
124 | old mode 100644 |
125 | new mode 100755 | |
126 | similarity index NUM% | |
127 | rename from no-funny | |
003d6dda EW |
128 | rename to "tabs\t,\" (dq) and spaces" |
129 | EOF | |
5be60078 JH |
130 | test_expect_success 'git diff-tree delete with-funny' \ |
131 | 'git diff-index -M -p $t0 | | |
4d2060ef | 132 | sed -e "s/index [0-9]*%/index NUM%/" >current && |
3af82863 | 133 | test_cmp expected current' |
4d2060ef | 134 | |
003d6dda EW |
135 | cat >expected <<\EOF |
136 | "tabs\t,\" (dq) and spaces" | |
137 | 1 files changed, 0 insertions(+), 0 deletions(-) | |
138 | EOF | |
5be60078 JH |
139 | test_expect_success 'git diff-tree rename with-funny applied' \ |
140 | 'git diff-index -M -p $t0 | | |
141 | git apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current && | |
3af82863 | 142 | test_cmp expected current' |
4d2060ef | 143 | |
003d6dda EW |
144 | cat > expected <<\EOF |
145 | no-funny | |
73ab46d6 | 146 | "tabs\t,\" (dq) and spaces" |
003d6dda EW |
147 | 2 files changed, 3 insertions(+), 3 deletions(-) |
148 | EOF | |
5be60078 JH |
149 | test_expect_success 'git diff-tree delete with-funny applied' \ |
150 | 'git diff-index -p $t0 | | |
151 | git apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current && | |
3af82863 | 152 | test_cmp expected current' |
4d2060ef | 153 | |
5be60078 JH |
154 | test_expect_success 'git apply non-git diff' \ |
155 | 'git diff-index -p $t0 | | |
4d2060ef | 156 | sed -ne "/^[-+@]/p" | |
5be60078 | 157 | git apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current && |
3af82863 | 158 | test_cmp expected current' |
4d2060ef JH |
159 | |
160 | test_done |