blob: a94286c8ec89823805989f4363072417e9c20165 [file] [log] [blame]
Eric Wong74a81222007-02-10 13:28:50 -08001#!/bin/sh
2# Copyright (c) 2007 Eric Wong
Nanako Shiraishi1364ff22008-09-08 19:02:08 +09003test_description='git svn globbing refspecs'
Eric Wong74a81222007-02-10 13:28:50 -08004. ./lib-git-svn.sh
5
6cat > expect.end <<EOF
7the end
8hi
9start a new branch
10initial
11EOF
12
Bryan Donlanf69e8362008-05-04 01:37:59 -040013test_expect_success 'test refspec globbing' '
Eric Wong74a81222007-02-10 13:28:50 -080014 mkdir -p trunk/src/a trunk/src/b trunk/doc &&
Bryan Donlanf69e8362008-05-04 01:37:59 -040015 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 Griepb47ddef2008-08-08 01:41:56 -070019 (
20 cd tmp &&
Eric Wong74a81222007-02-10 13:28:50 -080021 mkdir branches tags &&
Eygene Ryabinkinda083d62009-05-08 12:06:16 +040022 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 &&
Bryan Donlanf69e8362008-05-04 01:37:59 -040026 echo "hi" >> branches/start/src/b/readme &&
Eric Wongccb6b6f2007-02-13 17:38:58 -080027 poke branches/start/src/b/readme &&
Bryan Donlanf69e8362008-05-04 01:37:59 -040028 echo "hey" >> branches/start/src/a/readme &&
Eric Wongccb6b6f2007-02-13 17:38:58 -080029 poke branches/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/start tags/end &&
Bryan Donlanf69e8362008-05-04 01:37:59 -040033 echo "bye" >> tags/end/src/b/readme &&
Eric Wongccb6b6f2007-02-13 17:38:58 -080034 poke tags/end/src/b/readme &&
Bryan Donlanf69e8362008-05-04 01:37:59 -040035 echo "aye" >> tags/end/src/a/readme &&
Eric Wongccb6b6f2007-02-13 17:38:58 -080036 poke tags/end/src/a/readme &&
Eygene Ryabinkinda083d62009-05-08 12:06:16 +040037 svn_cmd commit -m "the end" &&
Bryan Donlanf69e8362008-05-04 01:37:59 -040038 echo "byebye" >> tags/end/src/b/readme &&
Eric Wongccb6b6f2007-02-13 17:38:58 -080039 poke tags/end/src/b/readme &&
Eygene Ryabinkinda083d62009-05-08 12:06:16 +040040 svn_cmd commit -m "nothing to see here"
Marcus Griepb47ddef2008-08-08 01:41:56 -070041 ) &&
Bryan Donlanf69e8362008-05-04 01:37:59 -040042 git config --add svn-remote.svn.url "$svnrepo" &&
Eric Wong74a81222007-02-10 13:28:50 -080043 git config --add svn-remote.svn.fetch \
Bryan Donlanf69e8362008-05-04 01:37:59 -040044 "trunk/src/a:refs/remotes/trunk" &&
Eric Wong74a81222007-02-10 13:28:50 -080045 git config --add svn-remote.svn.branches \
Bryan Donlanf69e8362008-05-04 01:37:59 -040046 "branches/*/src/a:refs/remotes/branches/*" &&
Eric Wong74a81222007-02-10 13:28:50 -080047 git config --add svn-remote.svn.tags\
Bryan Donlanf69e8362008-05-04 01:37:59 -040048 "tags/*/src/a:refs/remotes/tags/*" &&
Nanako Shiraishi1364ff22008-09-08 19:02:08 +090049 git svn multi-fetch &&
Eric Wong74a81222007-02-10 13:28:50 -080050 git log --pretty=oneline refs/remotes/tags/end | \
Bryan Donlanf69e8362008-05-04 01:37:59 -040051 sed -e "s/^.\{41\}//" > output.end &&
Marcus Griepb47ddef2008-08-08 01:41:56 -070052 test_cmp expect.end output.end &&
Elia Pinto38e94762016-01-12 10:45:14 +000053 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)" &&
Marcus Griep570d35c2008-08-08 01:41:57 -070057 test_must_fail git rev-parse refs/remotes/tags/end@3
Bryan Donlanf69e8362008-05-04 01:37:59 -040058 '
Eric Wong74a81222007-02-10 13:28:50 -080059
Eric Wong28710f72007-02-14 13:32:21 -080060echo try to try > expect.two
61echo nothing to see here >> expect.two
62cat expect.end >> expect.two
63
Bryan Donlanf69e8362008-05-04 01:37:59 -040064test_expect_success 'test left-hand-side only globbing' '
65 git config --add svn-remote.two.url "$svnrepo" &&
Eric Wong28710f72007-02-14 13:32:21 -080066 git config --add svn-remote.two.fetch trunk:refs/remotes/two/trunk &&
67 git config --add svn-remote.two.branches \
Bryan Donlanf69e8362008-05-04 01:37:59 -040068 "branches/*:refs/remotes/two/branches/*" &&
Eric Wong28710f72007-02-14 13:32:21 -080069 git config --add svn-remote.two.tags \
Bryan Donlanf69e8362008-05-04 01:37:59 -040070 "tags/*:refs/remotes/two/tags/*" &&
Marcus Griepb47ddef2008-08-08 01:41:56 -070071 (
72 cd tmp &&
Bryan Donlanf69e8362008-05-04 01:37:59 -040073 echo "try try" >> tags/end/src/b/readme &&
Eric Wong28710f72007-02-14 13:32:21 -080074 poke tags/end/src/b/readme &&
Eygene Ryabinkinda083d62009-05-08 12:06:16 +040075 svn_cmd commit -m "try to try"
Marcus Griepb47ddef2008-08-08 01:41:56 -070076 ) &&
Nanako Shiraishi1364ff22008-09-08 19:02:08 +090077 git svn fetch two &&
Elia Pinto38e94762016-01-12 10:45:14 +000078 test $(git rev-list refs/remotes/two/tags/end | wc -l) -eq 6 &&
79 test $(git rev-list refs/remotes/two/branches/start | wc -l) -eq 3 &&
80 test $(git rev-parse refs/remotes/two/branches/start~2) = \
81 $(git rev-parse refs/remotes/two/trunk) &&
82 test $(git rev-parse refs/remotes/two/tags/end~3) = \
83 $(git rev-parse refs/remotes/two/branches/start) &&
Eric Wong28710f72007-02-14 13:32:21 -080084 git log --pretty=oneline refs/remotes/two/tags/end | \
Bryan Donlanf69e8362008-05-04 01:37:59 -040085 sed -e "s/^.\{41\}//" > output.two &&
Marcus Griepb47ddef2008-08-08 01:41:56 -070086 test_cmp expect.two output.two
87 '
88
Eric Wong62335bb2016-01-14 03:59:48 +000089test_expect_success 'prepare test disallow multi-globs' "
90cat >expect.three <<EOF
91Only one set of wildcards (e.g. '*' or '*/*/*') is supported: branches/*/t/*
92
93EOF
94 "
Marcus Griepb47ddef2008-08-08 01:41:56 -070095
96test_expect_success 'test disallow multi-globs' '
97 git config --add svn-remote.three.url "$svnrepo" &&
98 git config --add svn-remote.three.fetch \
99 trunk:refs/remotes/three/trunk &&
100 git config --add svn-remote.three.branches \
Marcus Griep570d35c2008-08-08 01:41:57 -0700101 "branches/*/t/*:refs/remotes/three/branches/*" &&
Marcus Griepb47ddef2008-08-08 01:41:56 -0700102 git config --add svn-remote.three.tags \
103 "tags/*/*:refs/remotes/three/tags/*" &&
104 (
105 cd tmp &&
106 echo "try try" >> tags/end/src/b/readme &&
107 poke tags/end/src/b/readme &&
Eygene Ryabinkinda083d62009-05-08 12:06:16 +0400108 svn_cmd commit -m "try to try"
Marcus Griepb47ddef2008-08-08 01:41:56 -0700109 ) &&
Nanako Shiraishi1364ff22008-09-08 19:02:08 +0900110 test_must_fail git svn fetch three 2> stderr.three &&
Marcus Griepb47ddef2008-08-08 01:41:56 -0700111 test_cmp expect.three stderr.three
Bryan Donlanf69e8362008-05-04 01:37:59 -0400112 '
Eric Wong28710f72007-02-14 13:32:21 -0800113
Eric Wong74a81222007-02-10 13:28:50 -0800114test_done