1#!/bin/sh
2#
3# Copyright (c) 2006 Eric Wong
4#
5
6test_description='git-svn --follow-parent fetching'
7. ./lib-git-svn.sh
8
9test_expect_success 'initialize repo' "
10 mkdir import &&
11 cd import &&
12 mkdir -p trunk &&
13 echo hello > trunk/readme &&
14 svn import -m 'initial' . $svnrepo &&
15 cd .. &&
16 svn co $svnrepo wc &&
17 cd wc &&
18 echo world >> trunk/readme &&
19 poke trunk/readme &&
20 svn commit -m 'another commit' &&
21 svn up &&
22 svn mv -m 'rename to thunk' trunk thunk &&
23 svn up &&
24 echo goodbye >> thunk/readme &&
25 poke thunk/readme &&
26 svn commit -m 'bye now' &&
27 cd ..
28 "
29
30test_expect_success 'init and fetch --follow-parent a moved directory' "
31 git-svn init -i thunk $svnrepo/thunk &&
32 git-svn fetch --follow-parent -i thunk &&
33 test \"\`git-rev-parse --verify refs/remotes/thunk@2\`\" \
34 = \"\`git-rev-parse --verify refs/remotes/thunk~1\`\" &&
35 test \"\`git-cat-file blob refs/remotes/thunk:readme |\
36 sed -n -e '3p'\`\" = goodbye &&
37 test -n \"\`git-config --get svn-remote.git-svn.fetch \
38 '^trunk:refs/remotes/thunk@2$'\`\"
39 "
40
41test_expect_success 'init and fetch from one svn-remote' "
42 git-repo-config svn-remote.git-svn.url $svnrepo &&
43 git-repo-config --add svn-remote.git-svn.fetch \
44 trunk:refs/remotes/svn/trunk &&
45 git-repo-config --add svn-remote.git-svn.fetch \
46 thunk:refs/remotes/svn/thunk &&
47 git-svn fetch --follow-parent -i svn/thunk &&
48 test \"\`git-rev-parse --verify refs/remotes/svn/trunk\`\" \
49 = \"\`git-rev-parse --verify refs/remotes/svn/thunk~1\`\" &&
50 test \"\`git-cat-file blob refs/remotes/svn/thunk:readme |\
51 sed -n -e '3p'\`\" = goodbye
52 "
53
54test_expect_success 'follow deleted parent' "
55 svn cp -m 'resurrecting trunk as junk' \
56 -r2 $svnrepo/trunk $svnrepo/junk &&
57 git-repo-config --add svn-remote.git-svn.fetch \
58 junk:refs/remotes/svn/junk &&
59 git-svn fetch --follow-parent -i svn/thunk &&
60 git-svn fetch -i svn/junk --follow-parent &&
61 test -z \"\`git diff svn/junk svn/trunk\`\" &&
62 test \"\`git merge-base svn/junk svn/trunk\`\" \
63 = \"\`git rev-parse svn/trunk\`\"
64 "
65
66test_expect_success 'follow larger parent' "
67 mkdir -p import/trunk/thunk/bump/thud &&
68 echo hi > import/trunk/thunk/bump/thud/file &&
69 svn import -m 'import a larger parent' import $svnrepo/larger-parent &&
70 svn cp -m 'hi' $svnrepo/larger-parent $svnrepo/another-larger &&
71 git-svn init -i larger $svnrepo/another-larger/trunk/thunk/bump/thud &&
72 git-svn fetch -i larger --follow-parent &&
73 git-rev-parse --verify refs/remotes/larger &&
74 git-rev-parse --verify \
75 refs/remotes/larger-parent/trunk/thunk/bump/thud &&
76 test \"\`git-merge-base \
77 refs/remotes/larger-parent/trunk/thunk/bump/thud \
78 refs/remotes/larger\`\" = \
79 \"\`git-rev-parse refs/remotes/larger\`\"
80 true
81 "
82
83test_expect_success 'follow higher-level parent' "
84 svn mkdir -m 'follow higher-level parent' $svnrepo/blob &&
85 svn co $svnrepo/blob blob &&
86 cd blob &&
87 echo hi > hi &&
88 svn add hi &&
89 svn commit -m 'hihi' &&
90 cd ..
91 svn mkdir -m 'new glob at top level' $svnrepo/glob &&
92 svn mv -m 'move blob down a level' $svnrepo/blob $svnrepo/glob/blob &&
93 git-svn init -i blob $svnrepo/glob/blob &&
94 git-svn fetch -i blob --follow-parent
95 "
96
97test_expect_success 'follow deleted directory' "
98 svn mv -m 'bye!' $svnrepo/glob/blob/hi $svnrepo/glob/blob/bye&&
99 svn rm -m 'remove glob' $svnrepo/glob &&
100 git-svn init -i glob $svnrepo/glob &&
101 git-svn fetch -i glob &&
102 test \"\`git cat-file blob refs/remotes/glob~1:blob/bye\`\" = hi &&
103 test -z \"\`git ls-tree -z refs/remotes/glob\`\"
104 "
105
106# ref: r9270 of the Subversion repository: (http://svn.collab.net/repos/svn)
107# in trunk/subversion/bindings/swig/perl
108test_expect_success '' "
109 mkdir -p import/trunk/subversion/bindings/swig/perl/t &&
110 for i in a b c ; do \
111 echo \$i > import/trunk/subversion/bindings/swig/perl/\$i.pm &&
112 echo _\$i > import/trunk/subversion/bindings/swig/perl/t/\$i.t; \
113 done &&
114 echo 'bad delete test' > \
115 import/trunk/subversion/bindings/swig/perl/t/larger-parent &&
116 echo 'bad delete test 2' > \
117 import/trunk/subversion/bindings/swig/perl/another-larger &&
118 cd import &&
119 svn import -m 'r9270 test' . $svnrepo/r9270 &&
120 cd .. &&
121 svn co $svnrepo/r9270/trunk/subversion/bindings/swig/perl r9270 &&
122 cd r9270 &&
123 svn mkdir native &&
124 svn mv t native/t &&
125 for i in a b c; do svn mv \$i.pm native/\$i.pm; done &&
126 echo z >> native/t/c.t &&
127 svn commit -m 'reorg test' &&
128 cd .. &&
129 git-svn init -i r9270-t \
130 $svnrepo/r9270/trunk/subversion/bindings/swig/perl/native/t &&
131 git-svn fetch -i r9270-t --follow-parent &&
132 test \`git rev-list r9270-t | wc -l\` -eq 2 &&
133 test \"\`git ls-tree --name-only r9270-t~1\`\" = \
134 \"\`git ls-tree --name-only r9270-t\`\"
135 "
136
137test_debug 'gitk --all &'
138
139test_done