]> git.ipfire.org Git - thirdparty/git.git/blame - t/t3300-funny-names.sh
Add tests for funny pathnames.
[thirdparty/git.git] / t / t3300-funny-names.sh
CommitLineData
4d2060ef
JH
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'
16
17cat >"$p0" <<\EOF
181. A quick brown fox jumps over the lazy cat, oops dog.
192. A quick brown fox jumps over the lazy cat, oops dog.
203. A quick brown fox jumps over the lazy cat, oops dog.
21EOF
22
23cat >"$p1" "$p0"
24
25echo 'no-funny' >expected
26test_expect_success 'git-ls-files no-funny' \
27 'git-update-index --add "$p0" &&
28 git-ls-files >current &&
29 diff -u expected current'
30
31t0=`git-write-tree`
32echo "$t0" >t0
33
34echo 'no-funny
35"tabs\tand spaces"' >expected
36test_expect_success 'git-ls-files with-funny' \
37 'git-update-index --add "$p1" &&
38 git-ls-files >current &&
39 diff -u expected current'
40
41echo 'no-funny
42tabs and spaces' >expected
43test_expect_success 'git-ls-files -z with-funny' \
44 'git-ls-files -z | tr \\0 \\012 >current &&
45 diff -u expected current'
46
47t1=`git-write-tree`
48echo "$t1" >t1
49
50echo 'no-funny
51"tabs\tand spaces"' >expected
52test_expect_success 'git-ls-tree with funny' \
53 'git-ls-tree -r $t1 | sed -e "s/^[^ ]* //" >current &&
54 diff -u expected current'
55
56echo 'A "tabs\tand spaces"' >expected
57test_expect_success 'git-diff-index with-funny' \
58 'git-diff-index --name-status $t0 >current &&
59 diff -u expected current'
60
61test_expect_success 'git-diff-tree with-funny' \
62 'git-diff-tree --name-status $t0 $t1 >current &&
63 diff -u expected current'
64
65echo 'A
66tabs and spaces' >expected
67test_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
71test_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
75echo 'CNUM no-funny "tabs\tand spaces"' >expected
76test_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
81echo 'RNUM no-funny "tabs\tand spaces"' >expected
82test_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
88echo 'diff --git a/no-funny "b/tabs\tand spaces"
89similarity index NUM%
90rename from no-funny
91rename to "tabs\tand spaces"' >expected
92
93test_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
98chmod +x "$p1"
99echo 'diff --git a/no-funny "b/tabs\tand spaces"
100old mode 100644
101new mode 100755
102similarity index NUM%
103rename from no-funny
104rename to "tabs\tand spaces"' >expected
105
106test_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
111echo >expected ' "tabs\tand spaces"
112 1 files changed, 0 insertions(+), 0 deletions(-)'
113test_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
118echo >expected ' no-funny
119 "tabs\tand spaces"
120 2 files changed, 3 insertions(+), 3 deletions(-)'
121
122test_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
127test_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
133test_done