Merge branch 'ao/send-email-irt'
[git/kirr.git] / t / t9109-git-svn-multi-glob.sh
blobc318f9f946a35f0d13b90f67dd00a6817d77d989
1 #!/bin/sh
2 # Copyright (c) 2007 Eric Wong
3 test_description='git svn globbing refspecs'
4 . ./lib-git-svn.sh
6 cat > expect.end <<EOF
7 the end
8 hi
9 start a new branch
10 initial
11 EOF
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_cmd import -m "initial" trunk "$svnrepo"/trunk &&
18 svn_cmd co "$svnrepo" tmp &&
20 cd tmp &&
21 mkdir branches branches/v1 tags &&
22 svn_cmd add branches tags &&
23 svn_cmd cp trunk branches/v1/start &&
24 svn_cmd commit -m "start a new branch" &&
25 svn_cmd up &&
26 echo "hi" >> branches/v1/start/src/b/readme &&
27 poke branches/v1/start/src/b/readme &&
28 echo "hey" >> branches/v1/start/src/a/readme &&
29 poke branches/v1/start/src/a/readme &&
30 svn_cmd commit -m "hi" &&
31 svn_cmd up &&
32 svn_cmd cp branches/v1/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_cmd commit -m "the end" &&
38 echo "byebye" >> tags/end/src/b/readme &&
39 poke tags/end/src/b/readme &&
40 svn_cmd commit -m "nothing to see here"
41 ) &&
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/v1/start`" &&
55 test "`git rev-parse refs/remotes/branches/v1/start~2`" = \
56 "`git rev-parse refs/remotes/trunk`" &&
57 test_must_fail git rev-parse refs/remotes/tags/end@3
60 echo try to try > expect.two
61 echo nothing to see here >> expect.two
62 cat expect.end >> expect.two
64 test_expect_success 'test left-hand-side only globbing' '
65 git config --add svn-remote.two.url "$svnrepo" &&
66 git config --add svn-remote.two.fetch trunk:refs/remotes/two/trunk &&
67 git config --add svn-remote.two.branches \
68 "branches/*/*:refs/remotes/two/branches/*/*" &&
69 git config --add svn-remote.two.tags \
70 "tags/*:refs/remotes/two/tags/*" &&
72 cd tmp &&
73 echo "try try" >> tags/end/src/b/readme &&
74 poke tags/end/src/b/readme &&
75 svn_cmd commit -m "try to try"
76 ) &&
77 git svn fetch two &&
78 test `git rev-list refs/remotes/two/tags/end | wc -l` -eq 6 &&
79 test `git rev-list refs/remotes/two/branches/v1/start | wc -l` -eq 3 &&
80 test `git rev-parse refs/remotes/two/branches/v1/start~2` = \
81 `git rev-parse refs/remotes/two/trunk` &&
82 test `git rev-parse refs/remotes/two/tags/end~3` = \
83 `git rev-parse refs/remotes/two/branches/v1/start` &&
84 git log --pretty=oneline refs/remotes/two/tags/end | \
85 sed -e "s/^.\{41\}//" > output.two &&
86 test_cmp expect.two output.two
88 cat > expect.four <<EOF
89 adios
90 adding more
91 Changed 2 in v2/start
92 Another versioned branch
93 initial
94 EOF
96 test_expect_success 'test another branch' '
98 cd tmp &&
99 mkdir branches/v2 &&
100 svn_cmd add branches/v2 &&
101 svn_cmd cp trunk branches/v2/start &&
102 svn_cmd commit -m "Another versioned branch" &&
103 svn_cmd up &&
104 echo "hello" >> branches/v2/start/src/b/readme &&
105 poke branches/v2/start/src/b/readme &&
106 echo "howdy" >> branches/v2/start/src/a/readme &&
107 poke branches/v2/start/src/a/readme &&
108 svn_cmd commit -m "Changed 2 in v2/start" &&
109 svn_cmd up &&
110 svn_cmd cp branches/v2/start tags/next &&
111 echo "bye" >> tags/next/src/b/readme &&
112 poke tags/next/src/b/readme &&
113 echo "aye" >> tags/next/src/a/readme &&
114 poke tags/next/src/a/readme &&
115 svn_cmd commit -m "adding more" &&
116 echo "byebye" >> tags/next/src/b/readme &&
117 poke tags/next/src/b/readme &&
118 svn_cmd commit -m "adios"
119 ) &&
120 git config --add svn-remote.four.url "$svnrepo" &&
121 git config --add svn-remote.four.fetch trunk:refs/remotes/four/trunk &&
122 git config --add svn-remote.four.branches \
123 "branches/*/*:refs/remotes/four/branches/*/*" &&
124 git config --add svn-remote.four.tags \
125 "tags/*:refs/remotes/four/tags/*" &&
126 git svn fetch four &&
127 test `git rev-list refs/remotes/four/tags/next | wc -l` -eq 5 &&
128 test `git rev-list refs/remotes/four/branches/v2/start | wc -l` -eq 3 &&
129 test `git rev-parse refs/remotes/four/branches/v2/start~2` = \
130 `git rev-parse refs/remotes/four/trunk` &&
131 test `git rev-parse refs/remotes/four/tags/next~2` = \
132 `git rev-parse refs/remotes/four/branches/v2/start` &&
133 git log --pretty=oneline refs/remotes/four/tags/next | \
134 sed -e "s/^.\{41\}//" > output.four &&
135 test_cmp expect.four output.four
138 echo "Only one set of wildcard directories" \
139 "(e.g. '*' or '*/*/*') is supported: 'branches/*/t/*'" > expect.three
140 echo "" >> expect.three
142 test_expect_success 'test disallow multiple globs' '
143 git config --add svn-remote.three.url "$svnrepo" &&
144 git config --add svn-remote.three.fetch \
145 trunk:refs/remotes/three/trunk &&
146 git config --add svn-remote.three.branches \
147 "branches/*/t/*:refs/remotes/three/branches/*/*" &&
148 git config --add svn-remote.three.tags \
149 "tags/*:refs/remotes/three/tags/*" &&
151 cd tmp &&
152 echo "try try" >> tags/end/src/b/readme &&
153 poke tags/end/src/b/readme &&
154 svn_cmd commit -m "try to try"
155 ) &&
156 test_must_fail git svn fetch three 2> stderr.three &&
157 test_cmp expect.three stderr.three
160 test_done