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 >actual &&
51sed -e "s/^.\{41\}//" actual >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 &&
78git rev-list refs/remotes/two/tags/end >actual &&
79test_line_count = 6 actual &&
80git rev-list refs/remotes/two/branches/start >actual &&
81test_line_count = 3 actual &&
82test $(git rev-parse refs/remotes/two/branches/start~2) = \
83$(git rev-parse refs/remotes/two/trunk) &&
84test $(git rev-parse refs/remotes/two/tags/end~3) = \
85$(git rev-parse refs/remotes/two/branches/start) &&
86git log --pretty=oneline refs/remotes/two/tags/end >actual &&
87sed -e "s/^.\{41\}//" actual >output.two &&
88test_cmp expect.two output.two
89'
9091
test_expect_success 'prepare test disallow multi-globs' "
92cat >expect.three <<EOF
93Only one set of wildcards (e.g. '*' or '*/*/*') is supported: branches/*/t/*
9495
EOF
96"
9798
test_expect_success 'test disallow multi-globs' '
99git config --add svn-remote.three.url "$svnrepo" &&
100git config --add svn-remote.three.fetch \
101trunk:refs/remotes/three/trunk &&
102git config --add svn-remote.three.branches \
103"branches/*/t/*:refs/remotes/three/branches/*" &&
104git config --add svn-remote.three.tags \
105"tags/*/*:refs/remotes/three/tags/*" &&
106(
107cd tmp &&
108echo "try try" >> tags/end/src/b/readme &&
109poke tags/end/src/b/readme &&
110svn_cmd commit -m "try to try"
111) &&
112test_must_fail git svn fetch three 2> stderr.three &&
113test_cmp expect.three stderr.three
114'
115116
test_done