Eric Wong | a00439a | 2006-06-27 19:39:13 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Copyright (c) 2006 Eric Wong |
| 4 | # |
| 5 | |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 6 | test_description='git svn fetching' |
Eric Wong | a00439a | 2006-06-27 19:39:13 -0700 | [diff] [blame] | 7 | . ./lib-git-svn.sh |
| 8 | |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 9 | test_expect_success 'initialize repo' ' |
Eric Wong | a00439a | 2006-06-27 19:39:13 -0700 | [diff] [blame] | 10 | mkdir import && |
Jonathan Nieder | 18a8269 | 2010-09-06 20:42:54 -0500 | [diff] [blame] | 11 | ( |
| 12 | cd import && |
| 13 | mkdir -p trunk && |
| 14 | echo hello >trunk/readme && |
| 15 | svn_cmd import -m "initial" . "$svnrepo" |
Jens Lehmann | fd4ec4f | 2010-09-06 20:39:54 +0200 | [diff] [blame] | 16 | ) && |
Eygene Ryabinkin | da083d6 | 2009-05-08 12:06:16 +0400 | [diff] [blame] | 17 | svn_cmd co "$svnrepo" wc && |
Jonathan Nieder | 18a8269 | 2010-09-06 20:42:54 -0500 | [diff] [blame] | 18 | ( |
| 19 | cd wc && |
| 20 | echo world >>trunk/readme && |
| 21 | poke trunk/readme && |
| 22 | svn_cmd commit -m "another commit" && |
| 23 | svn_cmd up && |
| 24 | svn_cmd mv trunk thunk && |
| 25 | echo goodbye >>thunk/readme && |
| 26 | poke thunk/readme && |
| 27 | svn_cmd commit -m "bye now" |
Jens Lehmann | fd4ec4f | 2010-09-06 20:39:54 +0200 | [diff] [blame] | 28 | ) |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 29 | ' |
Eric Wong | a00439a | 2006-06-27 19:39:13 -0700 | [diff] [blame] | 30 | |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 31 | test_expect_success 'init and fetch a moved directory' ' |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 32 | git svn init --minimize-url -i thunk "$svnrepo"/thunk && |
| 33 | git svn fetch -i thunk && |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 34 | test "`git rev-parse --verify refs/remotes/thunk@2`" \ |
| 35 | = "`git rev-parse --verify refs/remotes/thunk~1`" && |
| 36 | test "`git cat-file blob refs/remotes/thunk:readme |\ |
| 37 | sed -n -e "3p"`" = goodbye && |
| 38 | test -z "`git config --get svn-remote.svn.fetch \ |
| 39 | "^trunk:refs/remotes/thunk@2$"`" |
| 40 | ' |
Eric Wong | a00439a | 2006-06-27 19:39:13 -0700 | [diff] [blame] | 41 | |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 42 | test_expect_success 'init and fetch from one svn-remote' ' |
| 43 | git config svn-remote.svn.url "$svnrepo" && |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 44 | git config --add svn-remote.svn.fetch \ |
Eric Wong | 8b8fc06 | 2007-01-22 11:44:57 -0800 | [diff] [blame] | 45 | trunk:refs/remotes/svn/trunk && |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 46 | git config --add svn-remote.svn.fetch \ |
Eric Wong | 8b8fc06 | 2007-01-22 11:44:57 -0800 | [diff] [blame] | 47 | thunk:refs/remotes/svn/thunk && |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 48 | git svn fetch -i svn/thunk && |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 49 | test "`git rev-parse --verify refs/remotes/svn/trunk`" \ |
| 50 | = "`git rev-parse --verify refs/remotes/svn/thunk~1`" && |
| 51 | test "`git cat-file blob refs/remotes/svn/thunk:readme |\ |
| 52 | sed -n -e "3p"`" = goodbye |
| 53 | ' |
Eric Wong | 8b8fc06 | 2007-01-22 11:44:57 -0800 | [diff] [blame] | 54 | |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 55 | test_expect_success 'follow deleted parent' ' |
Eygene Ryabinkin | da083d6 | 2009-05-08 12:06:16 +0400 | [diff] [blame] | 56 | (svn_cmd cp -m "resurrecting trunk as junk" \ |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 57 | "$svnrepo"/trunk@2 "$svnrepo"/junk || |
| 58 | svn cp -m "resurrecting trunk as junk" \ |
| 59 | -r2 "$svnrepo"/trunk "$svnrepo"/junk) && |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 60 | git config --add svn-remote.svn.fetch \ |
Eric Wong | a2003ab | 2007-01-22 15:22:50 -0800 | [diff] [blame] | 61 | junk:refs/remotes/svn/junk && |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 62 | git svn fetch -i svn/thunk && |
| 63 | git svn fetch -i svn/junk && |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 64 | test -z "`git diff svn/junk svn/trunk`" && |
| 65 | test "`git merge-base svn/junk svn/trunk`" \ |
| 66 | = "`git rev-parse svn/trunk`" |
| 67 | ' |
Eric Wong | a2003ab | 2007-01-22 15:22:50 -0800 | [diff] [blame] | 68 | |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 69 | test_expect_success 'follow larger parent' ' |
Eric Wong | 7f578c5 | 2007-01-24 02:16:25 -0800 | [diff] [blame] | 70 | mkdir -p import/trunk/thunk/bump/thud && |
| 71 | echo hi > import/trunk/thunk/bump/thud/file && |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 72 | svn import -m "import a larger parent" import "$svnrepo"/larger-parent && |
| 73 | svn cp -m "hi" "$svnrepo"/larger-parent "$svnrepo"/another-larger && |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 74 | git svn init --minimize-url -i larger \ |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 75 | "$svnrepo"/another-larger/trunk/thunk/bump/thud && |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 76 | git svn fetch -i larger && |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 77 | git rev-parse --verify refs/remotes/larger && |
| 78 | git rev-parse --verify \ |
Eric Wong | 7f578c5 | 2007-01-24 02:16:25 -0800 | [diff] [blame] | 79 | refs/remotes/larger-parent/trunk/thunk/bump/thud && |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 80 | test "`git merge-base \ |
Eric Wong | 7f578c5 | 2007-01-24 02:16:25 -0800 | [diff] [blame] | 81 | refs/remotes/larger-parent/trunk/thunk/bump/thud \ |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 82 | refs/remotes/larger`" = \ |
| 83 | "`git rev-parse refs/remotes/larger`" |
Eric Wong | 7f578c5 | 2007-01-24 02:16:25 -0800 | [diff] [blame] | 84 | true |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 85 | ' |
Eric Wong | 7f578c5 | 2007-01-24 02:16:25 -0800 | [diff] [blame] | 86 | |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 87 | test_expect_success 'follow higher-level parent' ' |
Jonathan Nieder | 18a8269 | 2010-09-06 20:42:54 -0500 | [diff] [blame] | 88 | svn mkdir -m "follow higher-level parent" "$svnrepo"/blob && |
| 89 | svn co "$svnrepo"/blob blob && |
| 90 | ( |
| 91 | cd blob && |
| 92 | echo hi > hi && |
| 93 | svn add hi && |
Jens Lehmann | fd4ec4f | 2010-09-06 20:39:54 +0200 | [diff] [blame] | 94 | svn commit -m "hihi" |
Jonathan Nieder | 18a8269 | 2010-09-06 20:42:54 -0500 | [diff] [blame] | 95 | ) && |
| 96 | svn mkdir -m "new glob at top level" "$svnrepo"/glob && |
| 97 | svn mv -m "move blob down a level" "$svnrepo"/blob "$svnrepo"/glob/blob && |
| 98 | git svn init --minimize-url -i blob "$svnrepo"/glob/blob && |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 99 | git svn fetch -i blob |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 100 | ' |
Eric Wong | 1492b42 | 2007-01-25 10:52:36 -0800 | [diff] [blame] | 101 | |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 102 | test_expect_success 'follow deleted directory' ' |
Eygene Ryabinkin | da083d6 | 2009-05-08 12:06:16 +0400 | [diff] [blame] | 103 | svn_cmd mv -m "bye!" "$svnrepo"/glob/blob/hi "$svnrepo"/glob/blob/bye && |
| 104 | svn_cmd rm -m "remove glob" "$svnrepo"/glob && |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 105 | git svn init --minimize-url -i glob "$svnrepo"/glob && |
| 106 | git svn fetch -i glob && |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 107 | test "`git cat-file blob refs/remotes/glob:blob/bye`" = hi && |
| 108 | test "`git ls-tree refs/remotes/glob | wc -l `" -eq 1 |
| 109 | ' |
Eric Wong | e5a0b24 | 2007-01-25 15:44:54 -0800 | [diff] [blame] | 110 | |
Eric Wong | 2b27f6c | 2007-01-28 04:59:05 -0800 | [diff] [blame] | 111 | # ref: r9270 of the Subversion repository: (http://svn.collab.net/repos/svn) |
| 112 | # in trunk/subversion/bindings/swig/perl |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 113 | test_expect_success 'follow-parent avoids deleting relevant info' ' |
Eric Wong | 2b27f6c | 2007-01-28 04:59:05 -0800 | [diff] [blame] | 114 | mkdir -p import/trunk/subversion/bindings/swig/perl/t && |
| 115 | for i in a b c ; do \ |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 116 | echo $i > import/trunk/subversion/bindings/swig/perl/$i.pm && |
| 117 | echo _$i > import/trunk/subversion/bindings/swig/perl/t/$i.t; \ |
Eric Wong | 2b27f6c | 2007-01-28 04:59:05 -0800 | [diff] [blame] | 118 | done && |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 119 | echo "bad delete test" > \ |
Eric Wong | 2b27f6c | 2007-01-28 04:59:05 -0800 | [diff] [blame] | 120 | import/trunk/subversion/bindings/swig/perl/t/larger-parent && |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 121 | echo "bad delete test 2" > \ |
Eric Wong | 2b27f6c | 2007-01-28 04:59:05 -0800 | [diff] [blame] | 122 | import/trunk/subversion/bindings/swig/perl/another-larger && |
Jonathan Nieder | 18a8269 | 2010-09-06 20:42:54 -0500 | [diff] [blame] | 123 | ( |
| 124 | cd import && |
| 125 | svn import -m "r9270 test" . "$svnrepo"/r9270 |
Jens Lehmann | fd4ec4f | 2010-09-06 20:39:54 +0200 | [diff] [blame] | 126 | ) && |
Eygene Ryabinkin | da083d6 | 2009-05-08 12:06:16 +0400 | [diff] [blame] | 127 | svn_cmd co "$svnrepo"/r9270/trunk/subversion/bindings/swig/perl r9270 && |
Jonathan Nieder | 18a8269 | 2010-09-06 20:42:54 -0500 | [diff] [blame] | 128 | ( |
| 129 | cd r9270 && |
| 130 | svn mkdir native && |
| 131 | svn mv t native/t && |
| 132 | for i in a b c |
| 133 | do |
| 134 | svn mv $i.pm native/$i.pm |
| 135 | done && |
| 136 | echo z >>native/t/c.t && |
| 137 | poke native/t/c.t && |
| 138 | svn commit -m "reorg test" |
Jens Lehmann | fd4ec4f | 2010-09-06 20:39:54 +0200 | [diff] [blame] | 139 | ) && |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 140 | git svn init --minimize-url -i r9270-t \ |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 141 | "$svnrepo"/r9270/trunk/subversion/bindings/swig/perl/native/t && |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 142 | git svn fetch -i r9270-t && |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 143 | test `git rev-list r9270-t | wc -l` -eq 2 && |
| 144 | test "`git ls-tree --name-only r9270-t~1`" = \ |
| 145 | "`git ls-tree --name-only r9270-t`" |
| 146 | ' |
Eric Wong | 2b27f6c | 2007-01-28 04:59:05 -0800 | [diff] [blame] | 147 | |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 148 | test_expect_success "track initial change if it was only made to parent" ' |
Eygene Ryabinkin | da083d6 | 2009-05-08 12:06:16 +0400 | [diff] [blame] | 149 | svn_cmd cp -m "wheee!" "$svnrepo"/r9270/trunk "$svnrepo"/r9270/drunk && |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 150 | git svn init --minimize-url -i r9270-d \ |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 151 | "$svnrepo"/r9270/drunk/subversion/bindings/swig/perl/native/t && |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 152 | git svn fetch -i r9270-d && |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 153 | test `git rev-list r9270-d | wc -l` -eq 3 && |
| 154 | test "`git ls-tree --name-only r9270-t`" = \ |
| 155 | "`git ls-tree --name-only r9270-d`" && |
| 156 | test "`git rev-parse r9270-t`" = \ |
| 157 | "`git rev-parse r9270-d~1`" |
| 158 | ' |
Eric Wong | 2893705 | 2007-01-30 00:35:18 -0800 | [diff] [blame] | 159 | |
Deskin Miller | 553589f | 2008-12-08 08:31:31 -0500 | [diff] [blame] | 160 | test_expect_success "follow-parent is atomic" ' |
| 161 | ( |
| 162 | cd wc && |
Eygene Ryabinkin | da083d6 | 2009-05-08 12:06:16 +0400 | [diff] [blame] | 163 | svn_cmd up && |
| 164 | svn_cmd mkdir stunk && |
Deskin Miller | 553589f | 2008-12-08 08:31:31 -0500 | [diff] [blame] | 165 | echo "trunk stunk" > stunk/readme && |
Eygene Ryabinkin | da083d6 | 2009-05-08 12:06:16 +0400 | [diff] [blame] | 166 | svn_cmd add stunk/readme && |
| 167 | svn_cmd ci -m "trunk stunk" && |
Deskin Miller | 553589f | 2008-12-08 08:31:31 -0500 | [diff] [blame] | 168 | echo "stunk like junk" >> stunk/readme && |
Eygene Ryabinkin | da083d6 | 2009-05-08 12:06:16 +0400 | [diff] [blame] | 169 | svn_cmd ci -m "really stunk" && |
Deskin Miller | 553589f | 2008-12-08 08:31:31 -0500 | [diff] [blame] | 170 | echo "stink stank stunk" >> stunk/readme && |
Eygene Ryabinkin | da083d6 | 2009-05-08 12:06:16 +0400 | [diff] [blame] | 171 | svn_cmd ci -m "even the grinch agrees" |
Deskin Miller | 553589f | 2008-12-08 08:31:31 -0500 | [diff] [blame] | 172 | ) && |
Eygene Ryabinkin | da083d6 | 2009-05-08 12:06:16 +0400 | [diff] [blame] | 173 | svn_cmd copy -m "stunk flunked" "$svnrepo"/stunk "$svnrepo"/flunk && |
Deskin Miller | 553589f | 2008-12-08 08:31:31 -0500 | [diff] [blame] | 174 | { svn cp -m "early stunk flunked too" \ |
| 175 | "$svnrepo"/stunk@17 "$svnrepo"/flunked || |
Eygene Ryabinkin | da083d6 | 2009-05-08 12:06:16 +0400 | [diff] [blame] | 176 | svn_cmd cp -m "early stunk flunked too" \ |
Deskin Miller | 553589f | 2008-12-08 08:31:31 -0500 | [diff] [blame] | 177 | -r17 "$svnrepo"/stunk "$svnrepo"/flunked; } && |
| 178 | git svn init --minimize-url -i stunk "$svnrepo"/stunk && |
| 179 | git svn fetch -i stunk && |
| 180 | git update-ref refs/remotes/flunk@18 refs/remotes/stunk~2 && |
| 181 | git update-ref -d refs/remotes/stunk && |
| 182 | git config --unset svn-remote.svn.fetch stunk && |
Adam Brewster | 6f5748e | 2009-08-11 23:14:27 -0400 | [diff] [blame] | 183 | mkdir -p "$GIT_DIR"/svn/refs/remotes/flunk@18 && |
| 184 | rev_map=$(cd "$GIT_DIR"/svn/refs/remotes/stunk && ls .rev_map*) && |
| 185 | dd if="$GIT_DIR"/svn/refs/remotes/stunk/$rev_map \ |
| 186 | of="$GIT_DIR"/svn/refs/remotes/flunk@18/$rev_map bs=24 count=1 && |
| 187 | rm -rf "$GIT_DIR"/svn/refs/remotes/stunk && |
Deskin Miller | 553589f | 2008-12-08 08:31:31 -0500 | [diff] [blame] | 188 | git svn init --minimize-url -i flunk "$svnrepo"/flunk && |
| 189 | git svn fetch -i flunk && |
| 190 | git svn init --minimize-url -i stunk "$svnrepo"/stunk && |
| 191 | git svn fetch -i stunk && |
| 192 | git svn init --minimize-url -i flunked "$svnrepo"/flunked && |
Jonathan Nieder | a48fcd8 | 2010-10-30 20:46:54 -0500 | [diff] [blame] | 193 | git svn fetch -i flunked && |
Deskin Miller | 553589f | 2008-12-08 08:31:31 -0500 | [diff] [blame] | 194 | test "`git rev-parse --verify refs/remotes/flunk@18`" \ |
| 195 | = "`git rev-parse --verify refs/remotes/stunk`" && |
| 196 | test "`git rev-parse --verify refs/remotes/flunk~1`" \ |
| 197 | = "`git rev-parse --verify refs/remotes/stunk`" && |
| 198 | test "`git rev-parse --verify refs/remotes/flunked~1`" \ |
| 199 | = "`git rev-parse --verify refs/remotes/stunk~1`" |
| 200 | ' |
| 201 | |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 202 | test_expect_success "track multi-parent paths" ' |
Eygene Ryabinkin | da083d6 | 2009-05-08 12:06:16 +0400 | [diff] [blame] | 203 | svn_cmd cp -m "resurrect /glob" "$svnrepo"/r9270 "$svnrepo"/glob && |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 204 | git svn multi-fetch && |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 205 | test `git cat-file commit refs/remotes/glob | \ |
| 206 | grep "^parent " | wc -l` -eq 2 |
| 207 | ' |
Eric Wong | b9dffd8 | 2007-02-09 01:28:30 -0800 | [diff] [blame] | 208 | |
Eric Wong | 8a60377 | 2007-01-31 02:45:50 -0800 | [diff] [blame] | 209 | test_expect_success "multi-fetch continues to work" " |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 210 | git svn multi-fetch |
Eric Wong | 8a60377 | 2007-01-31 02:45:50 -0800 | [diff] [blame] | 211 | " |
| 212 | |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 213 | test_expect_success "multi-fetch works off a 'clean' repository" ' |
| 214 | rm -r "$GIT_DIR/svn" "$GIT_DIR/refs/remotes" "$GIT_DIR/logs" && |
| 215 | mkdir "$GIT_DIR/svn" && |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 216 | git svn multi-fetch |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 217 | ' |
Eric Wong | 8a60377 | 2007-01-31 02:45:50 -0800 | [diff] [blame] | 218 | |
Eric Wong | a00439a | 2006-06-27 19:39:13 -0700 | [diff] [blame] | 219 | test_debug 'gitk --all &' |
| 220 | |
| 221 | test_done |