ccd7063e97bda4c0d186404e90ab256eb2ee5853
1#!/bin/sh
2#
3# Copyright (c) 2005 Junio C Hamano
4#
5
6test_description='Pathnames with funny characters.
7
8This test tries pathnames with funny characters in the working
9tree, index, and tree objects.
10'
11
12. ./test-lib.sh
13
14p0='no-funny'
15p1='tabs and spaces'
16p2='just space'
17
18cat >"$p0" <<\EOF
191. A quick brown fox jumps over the lazy cat, oops dog.
202. A quick brown fox jumps over the lazy cat, oops dog.
213. A quick brown fox jumps over the lazy cat, oops dog.
22EOF
23
24cat >"$p1" "$p0"
25echo 'Foo Bar Baz' >"$p2"
26
27echo 'just space
28no-funny' >expected
29test_expect_success 'git-ls-files no-funny' \
30 'git-update-index --add "$p0" "$p2" &&
31 git-ls-files >current &&
32 diff -u expected current'
33
34t0=`git-write-tree`
35echo "$t0" >t0
36
37echo 'just space
38no-funny
39"tabs\tand spaces"' >expected
40test_expect_success 'git-ls-files with-funny' \
41 'git-update-index --add "$p1" &&
42 git-ls-files >current &&
43 diff -u expected current'
44
45echo 'just space
46no-funny
47tabs and spaces' >expected
48test_expect_success 'git-ls-files -z with-funny' \
49 'git-ls-files -z | tr \\0 \\012 >current &&
50 diff -u expected current'
51
52t1=`git-write-tree`
53echo "$t1" >t1
54
55echo 'just space
56no-funny
57"tabs\tand spaces"' >expected
58test_expect_success 'git-ls-tree with funny' \
59 'git-ls-tree -r $t1 | sed -e "s/^[^ ]* //" >current &&
60 diff -u expected current'
61
62echo 'A "tabs\tand spaces"' >expected
63test_expect_success 'git-diff-index with-funny' \
64 'git-diff-index --name-status $t0 >current &&
65 diff -u expected current'
66
67test_expect_success 'git-diff-tree with-funny' \
68 'git-diff-tree --name-status $t0 $t1 >current &&
69 diff -u expected current'
70
71echo 'A
72tabs and spaces' >expected
73test_expect_success 'git-diff-index -z with-funny' \
74 'git-diff-index -z --name-status $t0 | tr \\0 \\012 >current &&
75 diff -u expected current'
76
77test_expect_success 'git-diff-tree -z with-funny' \
78 'git-diff-tree -z --name-status $t0 $t1 | tr \\0 \\012 >current &&
79 diff -u expected current'
80
81echo 'CNUM no-funny "tabs\tand spaces"' >expected
82test_expect_success 'git-diff-tree -C with-funny' \
83 'git-diff-tree -C --find-copies-harder --name-status \
84 $t0 $t1 | sed -e 's/^C[0-9]*/CNUM/' >current &&
85 diff -u expected current'
86
87echo 'RNUM no-funny "tabs\tand spaces"' >expected
88test_expect_success 'git-diff-tree delete with-funny' \
89 'git-update-index --force-remove "$p0" &&
90 git-diff-index -M --name-status \
91 $t0 | sed -e 's/^R[0-9]*/RNUM/' >current &&
92 diff -u expected current'
93
94echo 'diff --git a/no-funny "b/tabs\tand spaces"
95similarity index NUM%
96rename from no-funny
97rename to "tabs\tand spaces"' >expected
98
99test_expect_success 'git-diff-tree delete with-funny' \
100 'git-diff-index -M -p $t0 |
101 sed -e "s/index [0-9]*%/index NUM%/" >current &&
102 diff -u expected current'
103
104chmod +x "$p1"
105echo 'diff --git a/no-funny "b/tabs\tand spaces"
106old mode 100644
107new mode 100755
108similarity index NUM%
109rename from no-funny
110rename to "tabs\tand spaces"' >expected
111
112test_expect_success 'git-diff-tree delete with-funny' \
113 'git-diff-index -M -p $t0 |
114 sed -e "s/index [0-9]*%/index NUM%/" >current &&
115 diff -u expected current'
116
117echo >expected ' "tabs\tand spaces"
118 1 files changed, 0 insertions(+), 0 deletions(-)'
119test_expect_success 'git-diff-tree rename with-funny applied' \
120 'git-diff-index -M -p $t0 |
121 git-apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
122 diff -u expected current'
123
124echo >expected ' no-funny
125 "tabs\tand spaces"
126 2 files changed, 3 insertions(+), 3 deletions(-)'
127
128test_expect_success 'git-diff-tree delete with-funny applied' \
129 'git-diff-index -p $t0 |
130 git-apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
131 diff -u expected current'
132
133test_expect_success 'git-apply non-git diff' \
134 'git-diff-index -p $t0 |
135 sed -ne "/^[-+@]/p" |
136 git-apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
137 diff -u expected current'
138
139test_done