1#!/bin/sh2# Copyright (c) 2007 Eric Wong3test_description='git svn globbing refspecs'4. ./lib-git-svn.sh56cat > expect.end <<EOF7the end8hi9start a new branch10initial11EOF1213test_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@358'5960echo try to try > expect.two61echo nothing to see here >> expect.two62cat expect.end >> expect.two6364test_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.two89'9091test_expect_success 'prepare test disallow multi-globs' "92cat >expect.three <<EOF93Only one set of wildcards (e.g. '*' or '*/*/*') is supported: branches/*/t/*9495EOF96"9798test_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.three114'115116test_done