Merge branch 'jl/zlib-restore-nul-termination'
[git] / t / t9168-git-svn-partially-globbed-names.sh
1 #!/bin/sh
2 test_description='git svn globbing refspecs with prefixed globs'
3 . ./lib-git-svn.sh
4
5 test_expect_success 'prepare test refspec prefixed globbing' '
6         cat >expect.end <<EOF
7 the end
8 hi
9 start a new branch
10 initial
11 EOF
12         '
13
14 test_expect_success 'test refspec prefixed globbing' '
15         mkdir -p trunk/src/a trunk/src/b trunk/doc &&
16         echo "hello world" >trunk/src/a/readme &&
17         echo "goodbye world" >trunk/src/b/readme &&
18         svn_cmd import -m "initial" trunk "$svnrepo"/trunk &&
19         svn_cmd co "$svnrepo" tmp &&
20         (
21                 cd tmp &&
22                 mkdir branches tags &&
23                 svn_cmd add branches tags &&
24                 svn_cmd cp trunk branches/b_start &&
25                 svn_cmd commit -m "start a new branch" &&
26                 svn_cmd up &&
27                 echo "hi" >>branches/b_start/src/b/readme &&
28                 poke branches/b_start/src/b/readme &&
29                 echo "hey" >>branches/b_start/src/a/readme &&
30                 poke branches/b_start/src/a/readme &&
31                 svn_cmd commit -m "hi" &&
32                 svn_cmd up &&
33                 svn_cmd cp branches/b_start tags/t_end &&
34                 echo "bye" >>tags/t_end/src/b/readme &&
35                 poke tags/t_end/src/b/readme &&
36                 echo "aye" >>tags/t_end/src/a/readme &&
37                 poke tags/t_end/src/a/readme &&
38                 svn_cmd commit -m "the end" &&
39                 echo "byebye" >>tags/t_end/src/b/readme &&
40                 poke tags/t_end/src/b/readme &&
41                 svn_cmd commit -m "nothing to see here"
42         ) &&
43         git config --add svn-remote.svn.url "$svnrepo" &&
44         git config --add svn-remote.svn.fetch \
45                          "trunk/src/a:refs/remotes/trunk" &&
46         git config --add svn-remote.svn.branches \
47                          "branches/b_*/src/a:refs/remotes/branches/b_*" &&
48         git config --add svn-remote.svn.tags\
49                          "tags/t_*/src/a:refs/remotes/tags/t_*" &&
50         git svn multi-fetch &&
51         git log --pretty=oneline refs/remotes/tags/t_end >actual &&
52         sed -e "s/^.\{41\}//" actual >output.end &&
53         test_cmp expect.end output.end &&
54         test "$(git rev-parse refs/remotes/tags/t_end~1)" = \
55                 "$(git rev-parse refs/remotes/branches/b_start)" &&
56         test "$(git rev-parse refs/remotes/branches/b_start~2)" = \
57                 "$(git rev-parse refs/remotes/trunk)" &&
58         test_must_fail git rev-parse refs/remotes/tags/t_end@3
59         '
60
61 test_expect_success 'prepare test left-hand-side only prefixed globbing' '
62         echo try to try >expect.two &&
63         echo nothing to see here >>expect.two &&
64         cat expect.end >>expect.two
65         '
66
67 test_expect_success 'test left-hand-side only prefixed globbing' '
68         git config --add svn-remote.two.url "$svnrepo" &&
69         git config --add svn-remote.two.fetch trunk:refs/remotes/two/trunk &&
70         git config --add svn-remote.two.branches \
71                          "branches/b_*:refs/remotes/two/branches/*" &&
72         git config --add svn-remote.two.tags \
73                          "tags/t_*:refs/remotes/two/tags/*" &&
74         (
75                 cd tmp &&
76                 echo "try try" >>tags/t_end/src/b/readme &&
77                 poke tags/t_end/src/b/readme &&
78                 svn_cmd commit -m "try to try"
79         ) &&
80         git svn fetch two &&
81         git rev-list refs/remotes/two/tags/t_end >actual &&
82         test_line_count = 6 actual &&
83         git rev-list refs/remotes/two/branches/b_start >actual &&
84         test_line_count = 3 actual &&
85         test $(git rev-parse refs/remotes/two/branches/b_start~2) = \
86              $(git rev-parse refs/remotes/two/trunk) &&
87         test $(git rev-parse refs/remotes/two/tags/t_end~3) = \
88              $(git rev-parse refs/remotes/two/branches/b_start) &&
89         git log --pretty=oneline refs/remotes/two/tags/t_end >actual &&
90         sed -e "s/^.\{41\}//" actual >output.two &&
91         test_cmp expect.two output.two
92         '
93
94 test_expect_success 'prepare test prefixed globs match just prefix' '
95         cat >expect.three <<EOF
96 Tag commit to t_
97 Branch commit to b_
98 initial
99 EOF
100         '
101
102 test_expect_success 'test prefixed globs match just prefix' '
103         git config --add svn-remote.three.url "$svnrepo" &&
104         git config --add svn-remote.three.fetch \
105                          trunk:refs/remotes/three/trunk &&
106         git config --add svn-remote.three.branches \
107                          "branches/b_*:refs/remotes/three/branches/*" &&
108         git config --add svn-remote.three.tags \
109                          "tags/t_*:refs/remotes/three/tags/*" &&
110         (
111                 cd tmp &&
112                 svn_cmd cp trunk branches/b_ &&
113                 echo "Branch commit to b_" >>branches/b_/src/a/readme &&
114                 poke branches/b_/src/a/readme &&
115                 svn_cmd commit -m "Branch commit to b_" &&
116                 svn_cmd up && svn_cmd cp branches/b_ tags/t_ &&
117                 echo "Tag commit to t_" >>tags/t_/src/a/readme &&
118                 poke tags/t_/src/a/readme &&
119                 svn_cmd commit -m "Tag commit to t_" &&
120                 svn_cmd up
121         ) &&
122         git svn fetch three &&
123         git rev-list refs/remotes/three/branches/b_ >actual &&
124         test_line_count = 2 actual &&
125         git rev-list refs/remotes/three/tags/t_ >actual &&
126         test_line_count = 3 actual &&
127         test $(git rev-parse refs/remotes/three/branches/b_~1) = \
128              $(git rev-parse refs/remotes/three/trunk) &&
129         test $(git rev-parse refs/remotes/three/tags/t_~1) = \
130              $(git rev-parse refs/remotes/three/branches/b_) &&
131         git log --pretty=oneline refs/remotes/three/tags/t_ >actual &&
132         sed -e "s/^.\{41\}//" actual >output.three &&
133         test_cmp expect.three output.three
134         '
135
136 test_expect_success 'prepare test disallow prefixed multi-globs' "
137 cat >expect.four <<EOF
138 Only one set of wildcards (e.g. '*' or '*/*/*') is supported: branches/b_*/t/*
139
140 EOF
141         "
142
143 test_expect_success 'test disallow prefixed multi-globs' '
144         git config --add svn-remote.four.url "$svnrepo" &&
145         git config --add svn-remote.four.fetch \
146                          trunk:refs/remotes/four/trunk &&
147         git config --add svn-remote.four.branches \
148                          "branches/b_*/t/*:refs/remotes/four/branches/*" &&
149         git config --add svn-remote.four.tags \
150                          "tags/t_*/*:refs/remotes/four/tags/*" &&
151         (
152                 cd tmp &&
153                 echo "try try" >>tags/t_end/src/b/readme &&
154                 poke tags/t_end/src/b/readme &&
155                 svn_cmd commit -m "try to try"
156         ) &&
157         test_must_fail git svn fetch four 2>stderr.four &&
158         test_cmp expect.four stderr.four &&
159         git config --unset svn-remote.four.branches &&
160         git config --unset svn-remote.four.tags
161         '
162
163 test_expect_success 'prepare test globbing in the middle of the word' '
164         cat >expect.five <<EOF
165 Tag commit to fghij
166 Branch commit to abcde
167 initial
168 EOF
169         '
170
171 test_expect_success 'test globbing in the middle of the word' '
172         git config --add svn-remote.five.url "$svnrepo" &&
173         git config --add svn-remote.five.fetch \
174                          trunk:refs/remotes/five/trunk &&
175         git config --add svn-remote.five.branches \
176                          "branches/a*e:refs/remotes/five/branches/*" &&
177         git config --add svn-remote.five.tags \
178                          "tags/f*j:refs/remotes/five/tags/*" &&
179         (
180                 cd tmp &&
181                 svn_cmd cp trunk branches/abcde &&
182                 echo "Branch commit to abcde" >>branches/abcde/src/a/readme &&
183                 poke branches/b_/src/a/readme &&
184                 svn_cmd commit -m "Branch commit to abcde" &&
185                 svn_cmd up &&
186                 svn_cmd cp branches/abcde tags/fghij &&
187                 echo "Tag commit to fghij" >>tags/fghij/src/a/readme &&
188                 poke tags/fghij/src/a/readme &&
189                 svn_cmd commit -m "Tag commit to fghij" &&
190                 svn_cmd up
191         ) &&
192         git svn fetch five &&
193         git rev-list refs/remotes/five/branches/abcde >actual &&
194         test_line_count = 2 actual &&
195         git rev-list refs/remotes/five/tags/fghij >actual &&
196         test_line_count = 3 actual &&
197         test $(git rev-parse refs/remotes/five/branches/abcde~1) = \
198              $(git rev-parse refs/remotes/five/trunk) &&
199         test $(git rev-parse refs/remotes/five/tags/fghij~1) = \
200              $(git rev-parse refs/remotes/five/branches/abcde) &&
201         git log --pretty=oneline refs/remotes/five/tags/fghij >actual &&
202         sed -e "s/^.\{41\}//" actual >output.five &&
203         test_cmp expect.five output.five
204         '
205
206 test_expect_success 'prepare test disallow multiple asterisks in one word' "
207         echo \"Only one '*' is allowed in a pattern: 'a*c*e'\" >expect.six &&
208         echo \"\" >>expect.six
209         "
210
211 test_expect_success 'test disallow multiple asterisks in one word' '
212         git config --add svn-remote.six.url "$svnrepo" &&
213         git config --add svn-remote.six.fetch \
214                          trunk:refs/remotes/six/trunk &&
215         git config --add svn-remote.six.branches \
216                          "branches/a*c*e:refs/remotes/six/branches/*" &&
217         git config --add svn-remote.six.tags \
218                          "tags/f*h*j:refs/remotes/six/tags/*" &&
219         (
220                 cd tmp &&
221                 echo "try try" >>tags/fghij/src/b/readme &&
222                 poke tags/fghij/src/b/readme &&
223                 svn_cmd commit -m "try to try"
224         ) &&
225         test_must_fail git svn fetch six 2>stderr.six &&
226         test_cmp expect.six stderr.six
227         '
228
229 test_done