1#!/bin/sh
2# Copyright (c) 2007 Eric Wong
3test_description='git svn globbing refspecs'
4. ./lib-git-svn.sh
56
cat > expect.end <<EOF
7the end
8hi
9start a new branch
10initial
11EOF
1213
test_expect_success 'test refspec globbing' '
14mkdir -p trunk/src/a trunk/src/b trunk/doc &&
15echo "hello world" > trunk/src/a/readme &&
16echo "goodbye world" > trunk/src/b/readme &&
17svn_cmd import -m "initial" trunk "$svnrepo"/trunk &&
18svn_cmd co "$svnrepo" tmp &&
19(
20cd tmp &&
21mkdir branches tags &&
22svn_cmd add branches tags &&
23svn_cmd cp trunk branches/start &&
24svn_cmd commit -m "start a new branch" &&
25svn_cmd up &&
26echo "hi" >> branches/start/src/b/readme &&
27poke branches/start/src/b/readme &&
28echo "hey" >> branches/start/src/a/readme &&
29poke branches/start/src/a/readme &&
30svn_cmd commit -m "hi" &&
31svn_cmd up &&
32svn_cmd cp branches/start tags/end &&
33echo "bye" >> tags/end/src/b/readme &&
34poke tags/end/src/b/readme &&
35echo "aye" >> tags/end/src/a/readme &&
36poke tags/end/src/a/readme &&
37svn_cmd commit -m "the end" &&
38echo "byebye" >> tags/end/src/b/readme &&
39poke tags/end/src/b/readme &&
40svn_cmd commit -m "nothing to see here"
41) &&
42git config --add svn-remote.svn.url "$svnrepo" &&
43git config --add svn-remote.svn.fetch \
44"trunk/src/a:refs/remotes/trunk" &&
45git config --add svn-remote.svn.branches \
46"branches/*/src/a:refs/remotes/branches/*" &&
47git config --add svn-remote.svn.tags\
48"tags/*/src/a:refs/remotes/tags/*" &&
49git svn multi-fetch &&
50git log --pretty=oneline refs/remotes/tags/end | \
51sed -e "s/^.\{41\}//" > output.end &&
52test_cmp expect.end output.end &&
53test "$(git rev-parse refs/remotes/tags/end~1)" = \
54"$(git rev-parse refs/remotes/branches/start)" &&
55test "$(git rev-parse refs/remotes/branches/start~2)" = \
56"$(git rev-parse refs/remotes/trunk)" &&
57test_must_fail git rev-parse refs/remotes/tags/end@3
58'
5960
echo try to try > expect.two
61echo nothing to see here >> expect.two
62cat expect.end >> expect.two
6364
test_expect_success 'test left-hand-side only globbing' '
65git config --add svn-remote.two.url "$svnrepo" &&
66git config --add svn-remote.two.fetch trunk:refs/remotes/two/trunk &&
67git config --add svn-remote.two.branches \
68"branches/*:refs/remotes/two/branches/*" &&
69git config --add svn-remote.two.tags \
70"tags/*:refs/remotes/two/tags/*" &&
71(
72cd tmp &&
73echo "try try" >> tags/end/src/b/readme &&
74poke tags/end/src/b/readme &&
75svn_cmd commit -m "try to try"
76) &&
77git svn fetch two &&
78test $(git rev-list refs/remotes/two/tags/end | wc -l) -eq 6 &&
79test $(git rev-list refs/remotes/two/branches/start | wc -l) -eq 3 &&
80test $(git rev-parse refs/remotes/two/branches/start~2) = \
81$(git rev-parse refs/remotes/two/trunk) &&
82test $(git rev-parse refs/remotes/two/tags/end~3) = \
83$(git rev-parse refs/remotes/two/branches/start) &&
84git log --pretty=oneline refs/remotes/two/tags/end | \
85sed -e "s/^.\{41\}//" > output.two &&
86test_cmp expect.two output.two
87'
8889
test_expect_success 'prepare test disallow multi-globs' "
90cat >expect.three <<EOF
91Only one set of wildcards (e.g. '*' or '*/*/*') is supported: branches/*/t/*
9293
EOF
94"
9596
test_expect_success 'test disallow multi-globs' '
97git config --add svn-remote.three.url "$svnrepo" &&
98git config --add svn-remote.three.fetch \
99trunk:refs/remotes/three/trunk &&
100git config --add svn-remote.three.branches \
101"branches/*/t/*:refs/remotes/three/branches/*" &&
102git config --add svn-remote.three.tags \
103"tags/*/*:refs/remotes/three/tags/*" &&
104(
105cd tmp &&
106echo "try try" >> tags/end/src/b/readme &&
107poke tags/end/src/b/readme &&
108svn_cmd commit -m "try to try"
109) &&
110test_must_fail git svn fetch three 2> stderr.three &&
111test_cmp expect.three stderr.three
112'
113114
test_done