The twelfth batch
[git/gitster.git] / t / t9108-git-svn-glob.sh
blobd5939d4753ece809a762aa35a6f48663126ae506
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 tags &&
22 svn_cmd add branches tags &&
23 svn_cmd cp trunk branches/start &&
24 svn_cmd commit -m "start a new branch" &&
25 svn_cmd up &&
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 &&
30 svn_cmd commit -m "hi" &&
31 svn_cmd up &&
32 svn_cmd 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_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 >actual &&
51 cut -d" " -f2- actual >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)" &&
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 git rev-list refs/remotes/two/tags/end >actual &&
79 test_line_count = 6 actual &&
80 git rev-list refs/remotes/two/branches/start >actual &&
81 test_line_count = 3 actual &&
82 test $(git rev-parse refs/remotes/two/branches/start~2) = \
83 $(git rev-parse refs/remotes/two/trunk) &&
84 test $(git rev-parse refs/remotes/two/tags/end~3) = \
85 $(git rev-parse refs/remotes/two/branches/start) &&
86 git log --pretty=oneline refs/remotes/two/tags/end >actual &&
87 cut -d" " -f2- actual >output.two &&
88 test_cmp expect.two output.two
91 test_expect_success 'prepare test disallow multi-globs' "
92 cat >expect.three <<EOF
93 Only one set of wildcards (e.g. '*' or '*/*/*') is supported: branches/*/t/*
95 EOF
98 test_expect_success 'test disallow multi-globs' '
99 git config --add svn-remote.three.url "$svnrepo" &&
100 git config --add svn-remote.three.fetch \
101 trunk:refs/remotes/three/trunk &&
102 git config --add svn-remote.three.branches \
103 "branches/*/t/*:refs/remotes/three/branches/*" &&
104 git config --add svn-remote.three.tags \
105 "tags/*/*:refs/remotes/three/tags/*" &&
107 cd tmp &&
108 echo "try try" >> tags/end/src/b/readme &&
109 poke tags/end/src/b/readme &&
110 svn_cmd commit -m "try to try"
111 ) &&
112 test_must_fail git svn fetch three 2> stderr.three &&
113 test_cmp expect.three stderr.three
116 test_done