2 # Copyright (c) 2007 Eric Wong
3 test_description
='git-svn globbing refspecs'
13 test_expect_success
'test refspec globbing' '
14 mkdir -p trunk/src/a trunk/src/b trunk/doc &&
15 echo "hello world" > trunk/src/a/readme &&
16 echo "goodbye world" > trunk/src/b/readme &&
17 svn import -m "initial" trunk "$svnrepo"/trunk &&
18 svn co "$svnrepo" tmp &&
21 mkdir branches tags &&
22 svn add branches tags &&
23 svn cp trunk branches/start &&
24 svn commit -m "start a new branch" &&
26 echo "hi" >> branches/start/src/b/readme &&
27 poke branches/start/src/b/readme &&
28 echo "hey" >> branches/start/src/a/readme &&
29 poke branches/start/src/a/readme &&
32 svn cp branches/start tags/end &&
33 echo "bye" >> tags/end/src/b/readme &&
34 poke tags/end/src/b/readme &&
35 echo "aye" >> tags/end/src/a/readme &&
36 poke tags/end/src/a/readme &&
37 svn commit -m "the end" &&
38 echo "byebye" >> tags/end/src/b/readme &&
39 poke tags/end/src/b/readme &&
40 svn commit -m "nothing to see here"
42 git config --add svn-remote.svn.url "$svnrepo" &&
43 git config --add svn-remote.svn.fetch \
44 "trunk/src/a:refs/remotes/trunk" &&
45 git config --add svn-remote.svn.branches \
46 "branches/*/src/a:refs/remotes/branches/*" &&
47 git config --add svn-remote.svn.tags\
48 "tags/*/src/a:refs/remotes/tags/*" &&
49 git-svn multi-fetch &&
50 git log --pretty=oneline refs/remotes/tags/end | \
51 sed -e "s/^.\{41\}//" > output.end &&
52 test_cmp expect.end output.end &&
53 test "`git rev-parse refs/remotes/tags/end~1`" = \
54 "`git rev-parse refs/remotes/branches/start`" &&
55 test "`git rev-parse refs/remotes/branches/start~2`" = \
56 "`git rev-parse refs/remotes/trunk`"
59 echo try to try
> expect.two
60 echo nothing to see here
>> expect.two
61 cat expect.end
>> expect.two
63 test_expect_success
'test left-hand-side only globbing' '
64 git config --add svn-remote.two.url "$svnrepo" &&
65 git config --add svn-remote.two.fetch trunk:refs/remotes/two/trunk &&
66 git config --add svn-remote.two.branches \
67 "branches/*:refs/remotes/two/branches/*" &&
68 git config --add svn-remote.two.tags \
69 "tags/*:refs/remotes/two/tags/*" &&
72 echo "try try" >> tags/end/src/b/readme &&
73 poke tags/end/src/b/readme &&
74 svn commit -m "try to try"
77 test `git rev-list refs/remotes/two/tags/end | wc -l` -eq 6 &&
78 test `git rev-list refs/remotes/two/branches/start | wc -l` -eq 3 &&
79 test `git rev-parse refs/remotes/two/branches/start~2` = \
80 `git rev-parse refs/remotes/two/trunk` &&
81 test `git rev-parse refs/remotes/two/tags/end~3` = \
82 `git rev-parse refs/remotes/two/branches/start` &&
83 git log --pretty=oneline refs/remotes/two/tags/end | \
84 sed -e "s/^.\{41\}//" > output.two &&
85 test_cmp expect.two output.two
88 echo "Only one '*' wildcard expansion is supported (got 2): 'branches/*/*'" \
90 echo "" >> expect.three
92 test_expect_success
'test disallow multi-globs' '
93 git config --add svn-remote.three.url "$svnrepo" &&
94 git config --add svn-remote.three.fetch \
95 trunk:refs/remotes/three/trunk &&
96 git config --add svn-remote.three.branches \
97 "branches/*/*:refs/remotes/three/branches/*" &&
98 git config --add svn-remote.three.tags \
99 "tags/*/*:refs/remotes/three/tags/*" &&
102 echo "try try" >> tags/end/src/b/readme &&
103 poke tags/end/src/b/readme &&
104 svn commit -m "try to try"
106 test_must_fail git-svn fetch three 2> stderr.three &&
107 test_cmp expect.three stderr.three