blob: 5e0ad1917736591b50e65169216bd5fe80193989 [file] [log] [blame]
Eric Wonga00439a2006-06-27 19:39:13 -07001#!/bin/sh
2#
3# Copyright (c) 2006 Eric Wong
4#
5
Nanako Shiraishi1364ff22008-09-08 19:02:08 +09006test_description='git svn fetching'
Eric Wonga00439a2006-06-27 19:39:13 -07007. ./lib-git-svn.sh
8
Bryan Donlanf69e8362008-05-04 01:37:59 -04009test_expect_success 'initialize repo' '
Eric Wonga00439a2006-06-27 19:39:13 -070010 mkdir import &&
Jonathan Nieder18a82692010-09-06 20:42:54 -050011 (
12 cd import &&
13 mkdir -p trunk &&
14 echo hello >trunk/readme &&
15 svn_cmd import -m "initial" . "$svnrepo"
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +020016 ) &&
Eygene Ryabinkinda083d62009-05-08 12:06:16 +040017 svn_cmd co "$svnrepo" wc &&
Jonathan Nieder18a82692010-09-06 20:42:54 -050018 (
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 Lehmannfd4ec4f2010-09-06 20:39:54 +020028 )
Bryan Donlanf69e8362008-05-04 01:37:59 -040029 '
Eric Wonga00439a2006-06-27 19:39:13 -070030
Bryan Donlanf69e8362008-05-04 01:37:59 -040031test_expect_success 'init and fetch a moved directory' '
Nanako Shiraishi1364ff22008-09-08 19:02:08 +090032 git svn init --minimize-url -i thunk "$svnrepo"/thunk &&
33 git svn fetch -i thunk &&
Elia Pintocd914d82016-01-12 10:45:11 +000034 test "$(git rev-parse --verify refs/remotes/thunk@2)" \
35 = "$(git rev-parse --verify refs/remotes/thunk~1)" &&
Pratik Karkia4d4e322018-03-27 23:16:37 +054536 git cat-file blob refs/remotes/thunk:readme >actual &&
37 test "$(sed -n -e "3p" actual)" = goodbye &&
Elia Pintocd914d82016-01-12 10:45:11 +000038 test -z "$(git config --get svn-remote.svn.fetch \
39 "^trunk:refs/remotes/thunk@2$")"
Bryan Donlanf69e8362008-05-04 01:37:59 -040040 '
Eric Wonga00439a2006-06-27 19:39:13 -070041
Bryan Donlanf69e8362008-05-04 01:37:59 -040042test_expect_success 'init and fetch from one svn-remote' '
43 git config svn-remote.svn.url "$svnrepo" &&
Junio C Hamano5be60072007-07-02 22:52:14 -070044 git config --add svn-remote.svn.fetch \
Eric Wong8b8fc062007-01-22 11:44:57 -080045 trunk:refs/remotes/svn/trunk &&
Junio C Hamano5be60072007-07-02 22:52:14 -070046 git config --add svn-remote.svn.fetch \
Eric Wong8b8fc062007-01-22 11:44:57 -080047 thunk:refs/remotes/svn/thunk &&
Nanako Shiraishi1364ff22008-09-08 19:02:08 +090048 git svn fetch -i svn/thunk &&
Elia Pintocd914d82016-01-12 10:45:11 +000049 test "$(git rev-parse --verify refs/remotes/svn/trunk)" \
50 = "$(git rev-parse --verify refs/remotes/svn/thunk~1)" &&
Pratik Karkia4d4e322018-03-27 23:16:37 +054551 git cat-file blob refs/remotes/svn/thunk:readme >actual &&
52 test "$(sed -n -e "3p" actual)" = goodbye
Bryan Donlanf69e8362008-05-04 01:37:59 -040053 '
Eric Wong8b8fc062007-01-22 11:44:57 -080054
Bryan Donlanf69e8362008-05-04 01:37:59 -040055test_expect_success 'follow deleted parent' '
Eygene Ryabinkinda083d62009-05-08 12:06:16 +040056 (svn_cmd cp -m "resurrecting trunk as junk" \
Bryan Donlanf69e8362008-05-04 01:37:59 -040057 "$svnrepo"/trunk@2 "$svnrepo"/junk ||
58 svn cp -m "resurrecting trunk as junk" \
59 -r2 "$svnrepo"/trunk "$svnrepo"/junk) &&
Junio C Hamano5be60072007-07-02 22:52:14 -070060 git config --add svn-remote.svn.fetch \
Eric Wonga2003ab2007-01-22 15:22:50 -080061 junk:refs/remotes/svn/junk &&
Nanako Shiraishi1364ff22008-09-08 19:02:08 +090062 git svn fetch -i svn/thunk &&
63 git svn fetch -i svn/junk &&
Elia Pintocd914d82016-01-12 10:45:11 +000064 test -z "$(git diff svn/junk svn/trunk)" &&
65 test "$(git merge-base svn/junk svn/trunk)" \
66 = "$(git rev-parse svn/trunk)"
Bryan Donlanf69e8362008-05-04 01:37:59 -040067 '
Eric Wonga2003ab2007-01-22 15:22:50 -080068
Bryan Donlanf69e8362008-05-04 01:37:59 -040069test_expect_success 'follow larger parent' '
Eric Wong7f578c52007-01-24 02:16:25 -080070 mkdir -p import/trunk/thunk/bump/thud &&
71 echo hi > import/trunk/thunk/bump/thud/file &&
Bryan Donlanf69e8362008-05-04 01:37:59 -040072 svn import -m "import a larger parent" import "$svnrepo"/larger-parent &&
73 svn cp -m "hi" "$svnrepo"/larger-parent "$svnrepo"/another-larger &&
Nanako Shiraishi1364ff22008-09-08 19:02:08 +090074 git svn init --minimize-url -i larger \
Michael J Gruberb7a06e02015-03-20 15:32:56 +010075 "$svnrepo"/larger-parent/trunk/thunk/bump/thud &&
Nanako Shiraishi1364ff22008-09-08 19:02:08 +090076 git svn fetch -i larger &&
Michael J Gruberb7a06e02015-03-20 15:32:56 +010077 git svn init --minimize-url -i larger-parent \
78 "$svnrepo"/another-larger/trunk/thunk/bump/thud &&
79 git svn fetch -i larger-parent &&
Junio C Hamano5be60072007-07-02 22:52:14 -070080 git rev-parse --verify refs/remotes/larger &&
81 git rev-parse --verify \
Michael J Gruberb7a06e02015-03-20 15:32:56 +010082 refs/remotes/larger-parent &&
Elia Pintocd914d82016-01-12 10:45:11 +000083 test "$(git merge-base \
Michael J Gruberb7a06e02015-03-20 15:32:56 +010084 refs/remotes/larger-parent \
Elia Pintocd914d82016-01-12 10:45:11 +000085 refs/remotes/larger)" = \
86 "$(git rev-parse refs/remotes/larger)"
Bryan Donlanf69e8362008-05-04 01:37:59 -040087 '
Eric Wong7f578c52007-01-24 02:16:25 -080088
Bryan Donlanf69e8362008-05-04 01:37:59 -040089test_expect_success 'follow higher-level parent' '
Jonathan Nieder18a82692010-09-06 20:42:54 -050090 svn mkdir -m "follow higher-level parent" "$svnrepo"/blob &&
91 svn co "$svnrepo"/blob blob &&
92 (
93 cd blob &&
94 echo hi > hi &&
95 svn add hi &&
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +020096 svn commit -m "hihi"
Jonathan Nieder18a82692010-09-06 20:42:54 -050097 ) &&
98 svn mkdir -m "new glob at top level" "$svnrepo"/glob &&
99 svn mv -m "move blob down a level" "$svnrepo"/blob "$svnrepo"/glob/blob &&
100 git svn init --minimize-url -i blob "$svnrepo"/glob/blob &&
Nanako Shiraishi1364ff22008-09-08 19:02:08 +0900101 git svn fetch -i blob
Bryan Donlanf69e8362008-05-04 01:37:59 -0400102 '
Eric Wong1492b422007-01-25 10:52:36 -0800103
Bryan Donlanf69e8362008-05-04 01:37:59 -0400104test_expect_success 'follow deleted directory' '
Eygene Ryabinkinda083d62009-05-08 12:06:16 +0400105 svn_cmd mv -m "bye!" "$svnrepo"/glob/blob/hi "$svnrepo"/glob/blob/bye &&
106 svn_cmd rm -m "remove glob" "$svnrepo"/glob &&
Nanako Shiraishi1364ff22008-09-08 19:02:08 +0900107 git svn init --minimize-url -i glob "$svnrepo"/glob &&
108 git svn fetch -i glob &&
Elia Pintocd914d82016-01-12 10:45:11 +0000109 test "$(git cat-file blob refs/remotes/glob:blob/bye)" = hi &&
Pratik Karkia4d4e322018-03-27 23:16:37 +0545110 git ls-tree refs/remotes/glob >actual &&
111 test_line_count = 1 actual
Bryan Donlanf69e8362008-05-04 01:37:59 -0400112 '
Eric Wonge5a0b242007-01-25 15:44:54 -0800113
Eric Wong2b27f6c2007-01-28 04:59:05 -0800114# ref: r9270 of the Subversion repository: (http://svn.collab.net/repos/svn)
115# in trunk/subversion/bindings/swig/perl
Bryan Donlanf69e8362008-05-04 01:37:59 -0400116test_expect_success 'follow-parent avoids deleting relevant info' '
Eric Wong2b27f6c2007-01-28 04:59:05 -0800117 mkdir -p import/trunk/subversion/bindings/swig/perl/t &&
118 for i in a b c ; do \
Bryan Donlanf69e8362008-05-04 01:37:59 -0400119 echo $i > import/trunk/subversion/bindings/swig/perl/$i.pm &&
120 echo _$i > import/trunk/subversion/bindings/swig/perl/t/$i.t; \
Eric Wong2b27f6c2007-01-28 04:59:05 -0800121 done &&
Bryan Donlanf69e8362008-05-04 01:37:59 -0400122 echo "bad delete test" > \
Eric Wong2b27f6c2007-01-28 04:59:05 -0800123 import/trunk/subversion/bindings/swig/perl/t/larger-parent &&
Bryan Donlanf69e8362008-05-04 01:37:59 -0400124 echo "bad delete test 2" > \
Eric Wong2b27f6c2007-01-28 04:59:05 -0800125 import/trunk/subversion/bindings/swig/perl/another-larger &&
Jonathan Nieder18a82692010-09-06 20:42:54 -0500126 (
127 cd import &&
128 svn import -m "r9270 test" . "$svnrepo"/r9270
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +0200129 ) &&
Eygene Ryabinkinda083d62009-05-08 12:06:16 +0400130 svn_cmd co "$svnrepo"/r9270/trunk/subversion/bindings/swig/perl r9270 &&
Jonathan Nieder18a82692010-09-06 20:42:54 -0500131 (
132 cd r9270 &&
133 svn mkdir native &&
134 svn mv t native/t &&
135 for i in a b c
136 do
137 svn mv $i.pm native/$i.pm
138 done &&
139 echo z >>native/t/c.t &&
140 poke native/t/c.t &&
141 svn commit -m "reorg test"
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +0200142 ) &&
Nanako Shiraishi1364ff22008-09-08 19:02:08 +0900143 git svn init --minimize-url -i r9270-t \
Bryan Donlanf69e8362008-05-04 01:37:59 -0400144 "$svnrepo"/r9270/trunk/subversion/bindings/swig/perl/native/t &&
Nanako Shiraishi1364ff22008-09-08 19:02:08 +0900145 git svn fetch -i r9270-t &&
Elia Pintocd914d82016-01-12 10:45:11 +0000146 test $(git rev-list r9270-t | wc -l) -eq 2 &&
147 test "$(git ls-tree --name-only r9270-t~1)" = \
148 "$(git ls-tree --name-only r9270-t)"
Bryan Donlanf69e8362008-05-04 01:37:59 -0400149 '
Eric Wong2b27f6c2007-01-28 04:59:05 -0800150
Bryan Donlanf69e8362008-05-04 01:37:59 -0400151test_expect_success "track initial change if it was only made to parent" '
Eygene Ryabinkinda083d62009-05-08 12:06:16 +0400152 svn_cmd cp -m "wheee!" "$svnrepo"/r9270/trunk "$svnrepo"/r9270/drunk &&
Nanako Shiraishi1364ff22008-09-08 19:02:08 +0900153 git svn init --minimize-url -i r9270-d \
Bryan Donlanf69e8362008-05-04 01:37:59 -0400154 "$svnrepo"/r9270/drunk/subversion/bindings/swig/perl/native/t &&
Nanako Shiraishi1364ff22008-09-08 19:02:08 +0900155 git svn fetch -i r9270-d &&
Elia Pintocd914d82016-01-12 10:45:11 +0000156 test $(git rev-list r9270-d | wc -l) -eq 3 &&
157 test "$(git ls-tree --name-only r9270-t)" = \
158 "$(git ls-tree --name-only r9270-d)" &&
159 test "$(git rev-parse r9270-t)" = \
160 "$(git rev-parse r9270-d~1)"
Bryan Donlanf69e8362008-05-04 01:37:59 -0400161 '
Eric Wong28937052007-01-30 00:35:18 -0800162
Deskin Miller553589f2008-12-08 08:31:31 -0500163test_expect_success "follow-parent is atomic" '
164 (
165 cd wc &&
Eygene Ryabinkinda083d62009-05-08 12:06:16 +0400166 svn_cmd up &&
167 svn_cmd mkdir stunk &&
Deskin Miller553589f2008-12-08 08:31:31 -0500168 echo "trunk stunk" > stunk/readme &&
Eygene Ryabinkinda083d62009-05-08 12:06:16 +0400169 svn_cmd add stunk/readme &&
170 svn_cmd ci -m "trunk stunk" &&
Deskin Miller553589f2008-12-08 08:31:31 -0500171 echo "stunk like junk" >> stunk/readme &&
Eygene Ryabinkinda083d62009-05-08 12:06:16 +0400172 svn_cmd ci -m "really stunk" &&
Deskin Miller553589f2008-12-08 08:31:31 -0500173 echo "stink stank stunk" >> stunk/readme &&
Eygene Ryabinkinda083d62009-05-08 12:06:16 +0400174 svn_cmd ci -m "even the grinch agrees"
Deskin Miller553589f2008-12-08 08:31:31 -0500175 ) &&
Eygene Ryabinkinda083d62009-05-08 12:06:16 +0400176 svn_cmd copy -m "stunk flunked" "$svnrepo"/stunk "$svnrepo"/flunk &&
Deskin Miller553589f2008-12-08 08:31:31 -0500177 { svn cp -m "early stunk flunked too" \
178 "$svnrepo"/stunk@17 "$svnrepo"/flunked ||
Eygene Ryabinkinda083d62009-05-08 12:06:16 +0400179 svn_cmd cp -m "early stunk flunked too" \
Deskin Miller553589f2008-12-08 08:31:31 -0500180 -r17 "$svnrepo"/stunk "$svnrepo"/flunked; } &&
181 git svn init --minimize-url -i stunk "$svnrepo"/stunk &&
182 git svn fetch -i stunk &&
183 git update-ref refs/remotes/flunk@18 refs/remotes/stunk~2 &&
184 git update-ref -d refs/remotes/stunk &&
185 git config --unset svn-remote.svn.fetch stunk &&
Adam Brewster6f5748e2009-08-11 23:14:27 -0400186 mkdir -p "$GIT_DIR"/svn/refs/remotes/flunk@18 &&
187 rev_map=$(cd "$GIT_DIR"/svn/refs/remotes/stunk && ls .rev_map*) &&
188 dd if="$GIT_DIR"/svn/refs/remotes/stunk/$rev_map \
189 of="$GIT_DIR"/svn/refs/remotes/flunk@18/$rev_map bs=24 count=1 &&
190 rm -rf "$GIT_DIR"/svn/refs/remotes/stunk &&
Deskin Miller553589f2008-12-08 08:31:31 -0500191 git svn init --minimize-url -i flunk "$svnrepo"/flunk &&
192 git svn fetch -i flunk &&
193 git svn init --minimize-url -i stunk "$svnrepo"/stunk &&
194 git svn fetch -i stunk &&
195 git svn init --minimize-url -i flunked "$svnrepo"/flunked &&
Jonathan Niedera48fcd82010-10-30 20:46:54 -0500196 git svn fetch -i flunked &&
Elia Pintocd914d82016-01-12 10:45:11 +0000197 test "$(git rev-parse --verify refs/remotes/flunk@18)" \
198 = "$(git rev-parse --verify refs/remotes/stunk)" &&
199 test "$(git rev-parse --verify refs/remotes/flunk~1)" \
200 = "$(git rev-parse --verify refs/remotes/stunk)" &&
201 test "$(git rev-parse --verify refs/remotes/flunked~1)" \
202 = "$(git rev-parse --verify refs/remotes/stunk~1)"
Deskin Miller553589f2008-12-08 08:31:31 -0500203 '
204
Bryan Donlanf69e8362008-05-04 01:37:59 -0400205test_expect_success "track multi-parent paths" '
Eygene Ryabinkinda083d62009-05-08 12:06:16 +0400206 svn_cmd cp -m "resurrect /glob" "$svnrepo"/r9270 "$svnrepo"/glob &&
Nanako Shiraishi1364ff22008-09-08 19:02:08 +0900207 git svn multi-fetch &&
Pratik Karkia4d4e322018-03-27 23:16:37 +0545208 git cat-file commit refs/remotes/glob >actual &&
209 grep "^parent " actual >actual2 &&
210 test_line_count = 2 actual2
Bryan Donlanf69e8362008-05-04 01:37:59 -0400211 '
Eric Wongb9dffd82007-02-09 01:28:30 -0800212
Eric Wong8a603772007-01-31 02:45:50 -0800213test_expect_success "multi-fetch continues to work" "
Nanako Shiraishi1364ff22008-09-08 19:02:08 +0900214 git svn multi-fetch
Eric Wong8a603772007-01-31 02:45:50 -0800215 "
216
Bryan Donlanf69e8362008-05-04 01:37:59 -0400217test_expect_success "multi-fetch works off a 'clean' repository" '
Christian Couder78f28e22018-06-01 07:08:33 +0200218 rm -rf "$GIT_DIR/svn" &&
219 git for-each-ref --format="option no-deref%0adelete %(refname)" refs/remotes |
220 git update-ref --stdin &&
David Turnercbc5cf72018-05-23 07:25:17 +0200221 git reflog expire --all --expire=all &&
Bryan Donlanf69e8362008-05-04 01:37:59 -0400222 mkdir "$GIT_DIR/svn" &&
Nanako Shiraishi1364ff22008-09-08 19:02:08 +0900223 git svn multi-fetch
Bryan Donlanf69e8362008-05-04 01:37:59 -0400224 '
Eric Wong8a603772007-01-31 02:45:50 -0800225
Eric Wonga00439a2006-06-27 19:39:13 -0700226test_debug 'gitk --all &'
227
228test_done