git-svn: allow 'init' to work outside of tests
[git/haiku.git] / t / t9107-git-svn-migrate.sh
blob74a45ec6478012eb9172bc7700fc1abd997a8ac2
1 #!/bin/sh
2 # Copyright (c) 2006 Eric Wong
3 test_description='git-svn metadata migrations from previous versions'
4 . ./lib-git-svn.sh
6 test_expect_success 'setup old-looking metadata' "
7 cp $GIT_DIR/config $GIT_DIR/config-old-git-svn &&
8 git-svn init $svnrepo &&
9 git-svn fetch &&
10 for i in trunk branches/a branches/b tags/0.1 tags/0.2 tags/0.3; do
11 mkdir -p \$i && echo hello >> \$i/README || exit 1; done &&
12 git ls-files -o trunk branches tags | git update-index --add --stdin &&
13 git commit -m 'test' &&
14 git-svn dcommit &&
15 mv $GIT_DIR/svn/* $GIT_DIR/ &&
16 rmdir $GIT_DIR/svn &&
17 git-update-ref refs/heads/git-svn-HEAD refs/remotes/git-svn &&
18 git-update-ref refs/heads/svn-HEAD refs/remotes/git-svn &&
19 git-update-ref -d refs/remotes/git-svn refs/remotes/git-svn
22 head=`git rev-parse --verify refs/heads/git-svn-HEAD^0`
23 test_expect_success 'git-svn-HEAD is a real HEAD' "test -n '$head'"
25 test_expect_success 'initialize old-style (v0) git-svn layout' "
26 mkdir -p $GIT_DIR/git-svn/info $GIT_DIR/svn/info &&
27 echo $svnrepo > $GIT_DIR/git-svn/info/url &&
28 echo $svnrepo > $GIT_DIR/svn/info/url &&
29 git-svn migrate &&
30 ! test -d $GIT_DIR/git-svn &&
31 git-rev-parse --verify refs/remotes/git-svn^0 &&
32 git-rev-parse --verify refs/remotes/svn^0 &&
33 test \`git repo-config --get svn-remote.git-svn.url\` = '$svnrepo' &&
34 test \`git repo-config --get svn-remote.git-svn.fetch\` = \
35 ':refs/remotes/git-svn'
38 test_expect_success 'initialize a multi-repository repo' "
39 git-svn multi-init $svnrepo -T trunk -t tags -b branches &&
40 git-repo-config --get-all svn-remote.git-svn.fetch > fetch.out &&
41 grep '^trunk:refs/remotes/trunk$' fetch.out &&
42 grep '^branches/a:refs/remotes/a$' fetch.out &&
43 grep '^branches/b:refs/remotes/b$' fetch.out &&
44 grep '^tags/0\.1:refs/remotes/tags/0\.1$' fetch.out &&
45 grep '^tags/0\.2:refs/remotes/tags/0\.2$' fetch.out &&
46 grep '^tags/0\.3:refs/remotes/tags/0\.3$' fetch.out
49 # refs should all be different, but the trees should all be the same:
50 test_expect_success 'multi-fetch works on partial urls + paths' "
51 git-svn multi-fetch &&
52 for i in trunk a b tags/0.1 tags/0.2 tags/0.3; do
53 git rev-parse --verify refs/remotes/\$i^0 >> refs.out || exit 1;
54 done &&
55 test -z \"\`sort < refs.out | uniq -d\`\" &&
56 for i in trunk a b tags/0.1 tags/0.2 tags/0.3; do
57 for j in trunk a b tags/0.1 tags/0.2 tags/0.3; do
58 if test \$j != \$i; then continue; fi
59 test -z \"\`git diff refs/remotes/\$i \
60 refs/remotes/\$j\`\" ||exit 1; done; done
63 test_expect_success 'migrate --minimize on old multi-inited layout' "
64 git repo-config --unset-all svn-remote.git-svn.fetch &&
65 git repo-config --unset-all svn-remote.git-svn.url &&
66 rm -rf $GIT_DIR/svn &&
67 for i in \`cat fetch.out\`; do
68 path=\`expr \$i : '\\([^:]*\\):.*$'\`
69 ref=\`expr \$i : '[^:]*:refs/remotes/\\(.*\\)$'\`
70 if test -z \"\$ref\"; then continue; fi
71 if test -n \"\$path\"; then path=\"/\$path\"; fi
72 ( mkdir -p $GIT_DIR/svn/\$ref/info/ &&
73 echo $svnrepo\$path > $GIT_DIR/svn/\$ref/info/url ) || exit 1;
74 done &&
75 git-svn migrate --minimize &&
76 test -z \"\`git-repo-config -l |grep -v '^svn-remote\.git-svn\.'\`\" &&
77 git-repo-config --get-all svn-remote.git-svn.fetch > fetch.out &&
78 grep '^trunk:refs/remotes/trunk$' fetch.out &&
79 grep '^branches/a:refs/remotes/a$' fetch.out &&
80 grep '^branches/b:refs/remotes/b$' fetch.out &&
81 grep '^tags/0\.1:refs/remotes/tags/0\.1$' fetch.out &&
82 grep '^tags/0\.2:refs/remotes/tags/0\.2$' fetch.out &&
83 grep '^tags/0\.3:refs/remotes/tags/0\.3$' fetch.out
84 grep '^:refs/remotes/git-svn' fetch.out
87 test_done