blob: 648dcee1eac137b7e5507ae2717c8e3e79642faa [file] [log] [blame]
Marcus Griep570d35c2008-08-08 01:41:57 -07001#!/bin/sh
2# Copyright (c) 2007 Eric Wong
Nanako Shiraishi1364ff22008-09-08 19:02:08 +09003test_description='git svn globbing refspecs'
Marcus Griep570d35c2008-08-08 01:41:57 -07004. ./lib-git-svn.sh
5
6cat > expect.end <<EOF
7the end
8hi
9start a new branch
10initial
11EOF
12
13test_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 &&
Eygene Ryabinkinda083d62009-05-08 12:06:16 +040017 svn_cmd import -m "initial" trunk "$svnrepo"/trunk &&
18 svn_cmd co "$svnrepo" tmp &&
Marcus Griep570d35c2008-08-08 01:41:57 -070019 (
20 cd tmp &&
21 mkdir branches branches/v1 tags &&
Eygene Ryabinkinda083d62009-05-08 12:06:16 +040022 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 &&
Marcus Griep570d35c2008-08-08 01:41:57 -070026 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 &&
Eygene Ryabinkinda083d62009-05-08 12:06:16 +040030 svn_cmd commit -m "hi" &&
31 svn_cmd up &&
32 svn_cmd cp branches/v1/start tags/end &&
Marcus Griep570d35c2008-08-08 01:41:57 -070033 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 &&
Eygene Ryabinkinda083d62009-05-08 12:06:16 +040037 svn_cmd commit -m "the end" &&
Marcus Griep570d35c2008-08-08 01:41:57 -070038 echo "byebye" >> tags/end/src/b/readme &&
39 poke tags/end/src/b/readme &&
Eygene Ryabinkinda083d62009-05-08 12:06:16 +040040 svn_cmd commit -m "nothing to see here"
Marcus Griep570d35c2008-08-08 01:41:57 -070041 ) &&
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/*" &&
Nanako Shiraishi1364ff22008-09-08 19:02:08 +090049 git svn multi-fetch &&
Pratik Karkia4d4e322018-03-27 23:16:37 +054550 git log --pretty=oneline refs/remotes/tags/end >actual &&
brian m. carlson62814df2020-06-19 22:39:34 +000051 cut -d" " -f2- actual >output.end &&
Marcus Griep570d35c2008-08-08 01:41:57 -070052 test_cmp expect.end output.end &&
Elia Pinto1be2fa02016-01-12 10:45:15 +000053 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)" &&
Marcus Griep570d35c2008-08-08 01:41:57 -070057 test_must_fail git rev-parse refs/remotes/tags/end@3
58 '
59
60echo try to try > expect.two
61echo nothing to see here >> expect.two
62cat expect.end >> expect.two
63
64test_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/*" &&
71 (
72 cd tmp &&
73 echo "try try" >> tags/end/src/b/readme &&
74 poke tags/end/src/b/readme &&
Eygene Ryabinkinda083d62009-05-08 12:06:16 +040075 svn_cmd commit -m "try to try"
Marcus Griep570d35c2008-08-08 01:41:57 -070076 ) &&
Nanako Shiraishi1364ff22008-09-08 19:02:08 +090077 git svn fetch two &&
Pratik Karkia4d4e322018-03-27 23:16:37 +054578 git rev-list refs/remotes/two/tags/end >actual &&
79 test_line_count = 6 actual &&
80 git rev-list refs/remotes/two/branches/v1/start >actual &&
81 test_line_count = 3 actual &&
Elia Pinto1be2fa02016-01-12 10:45:15 +000082 test $(git rev-parse refs/remotes/two/branches/v1/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/v1/start) &&
Pratik Karkia4d4e322018-03-27 23:16:37 +054586 git log --pretty=oneline refs/remotes/two/tags/end >actual &&
brian m. carlson62814df2020-06-19 22:39:34 +000087 cut -d" " -f2- actual >output.two &&
Marcus Griep570d35c2008-08-08 01:41:57 -070088 test_cmp expect.two output.two
89 '
90cat > expect.four <<EOF
91adios
92adding more
93Changed 2 in v2/start
94Another versioned branch
95initial
96EOF
97
98test_expect_success 'test another branch' '
99 (
100 cd tmp &&
101 mkdir branches/v2 &&
Eygene Ryabinkinda083d62009-05-08 12:06:16 +0400102 svn_cmd add branches/v2 &&
103 svn_cmd cp trunk branches/v2/start &&
104 svn_cmd commit -m "Another versioned branch" &&
105 svn_cmd up &&
Marcus Griep570d35c2008-08-08 01:41:57 -0700106 echo "hello" >> branches/v2/start/src/b/readme &&
107 poke branches/v2/start/src/b/readme &&
108 echo "howdy" >> branches/v2/start/src/a/readme &&
109 poke branches/v2/start/src/a/readme &&
Eygene Ryabinkinda083d62009-05-08 12:06:16 +0400110 svn_cmd commit -m "Changed 2 in v2/start" &&
111 svn_cmd up &&
112 svn_cmd cp branches/v2/start tags/next &&
Marcus Griep570d35c2008-08-08 01:41:57 -0700113 echo "bye" >> tags/next/src/b/readme &&
114 poke tags/next/src/b/readme &&
115 echo "aye" >> tags/next/src/a/readme &&
116 poke tags/next/src/a/readme &&
Eygene Ryabinkinda083d62009-05-08 12:06:16 +0400117 svn_cmd commit -m "adding more" &&
Marcus Griep570d35c2008-08-08 01:41:57 -0700118 echo "byebye" >> tags/next/src/b/readme &&
119 poke tags/next/src/b/readme &&
Eygene Ryabinkinda083d62009-05-08 12:06:16 +0400120 svn_cmd commit -m "adios"
Marcus Griep570d35c2008-08-08 01:41:57 -0700121 ) &&
122 git config --add svn-remote.four.url "$svnrepo" &&
123 git config --add svn-remote.four.fetch trunk:refs/remotes/four/trunk &&
124 git config --add svn-remote.four.branches \
125 "branches/*/*:refs/remotes/four/branches/*/*" &&
126 git config --add svn-remote.four.tags \
127 "tags/*:refs/remotes/four/tags/*" &&
Nanako Shiraishi1364ff22008-09-08 19:02:08 +0900128 git svn fetch four &&
Pratik Karkia4d4e322018-03-27 23:16:37 +0545129 git rev-list refs/remotes/four/tags/next >actual &&
130 test_line_count = 5 actual &&
131 git rev-list refs/remotes/four/branches/v2/start >actual &&
132 test_line_count = 3 actual &&
Elia Pinto1be2fa02016-01-12 10:45:15 +0000133 test $(git rev-parse refs/remotes/four/branches/v2/start~2) = \
134 $(git rev-parse refs/remotes/four/trunk) &&
135 test $(git rev-parse refs/remotes/four/tags/next~2) = \
136 $(git rev-parse refs/remotes/four/branches/v2/start) &&
Pratik Karkia4d4e322018-03-27 23:16:37 +0545137 git log --pretty=oneline refs/remotes/four/tags/next >actual &&
brian m. carlson62814df2020-06-19 22:39:34 +0000138 cut -d" " -f2- actual >output.four &&
Marcus Griep570d35c2008-08-08 01:41:57 -0700139 test_cmp expect.four output.four
140 '
141
Eric Wong62335bb2016-01-14 03:59:48 +0000142test_expect_success 'prepare test disallow multiple globs' "
143cat >expect.three <<EOF
144Only one set of wildcards (e.g. '*' or '*/*/*') is supported: branches/*/t/*
145
146EOF
147 "
Marcus Griep570d35c2008-08-08 01:41:57 -0700148
149test_expect_success 'test disallow multiple globs' '
150 git config --add svn-remote.three.url "$svnrepo" &&
151 git config --add svn-remote.three.fetch \
152 trunk:refs/remotes/three/trunk &&
153 git config --add svn-remote.three.branches \
154 "branches/*/t/*:refs/remotes/three/branches/*/*" &&
155 git config --add svn-remote.three.tags \
156 "tags/*:refs/remotes/three/tags/*" &&
157 (
158 cd tmp &&
159 echo "try try" >> tags/end/src/b/readme &&
160 poke tags/end/src/b/readme &&
Eygene Ryabinkinda083d62009-05-08 12:06:16 +0400161 svn_cmd commit -m "try to try"
Marcus Griep570d35c2008-08-08 01:41:57 -0700162 ) &&
Nanako Shiraishi1364ff22008-09-08 19:02:08 +0900163 test_must_fail git svn fetch three 2> stderr.three &&
Marcus Griep570d35c2008-08-08 01:41:57 -0700164 test_cmp expect.three stderr.three
165 '
166
167test_done