]> git.ipfire.org Git - thirdparty/git.git/blame - t/t9107-git-svn-migrate.sh
completion: add new __gitcompadd helper
[thirdparty/git.git] / t / t9107-git-svn-migrate.sh
CommitLineData
706587fc
EW
1#!/bin/sh
2# Copyright (c) 2006 Eric Wong
1364ff27 3test_description='git svn metadata migrations from previous versions'
706587fc
EW
4. ./lib-git-svn.sh
5
f69e836f
BD
6test_expect_success 'setup old-looking metadata' '
7 cp "$GIT_DIR"/config "$GIT_DIR"/config-old-git-svn &&
97f6987a 8 mkdir import &&
18a82692
JN
9 (
10 cd import &&
11 for i in trunk branches/a branches/b tags/0.1 tags/0.2 tags/0.3
12 do
13 mkdir -p $i &&
14 echo hello >>$i/README ||
15 exit 1
16 done &&
da083d68 17 svn_cmd import -m test . "$svnrepo"
18a82692 18 ) &&
1364ff27
NS
19 git svn init "$svnrepo" &&
20 git svn fetch &&
6f5748e1 21 rm -rf "$GIT_DIR"/svn &&
16805d3e
NS
22 git update-ref refs/heads/git-svn-HEAD refs/${remotes_git_svn} &&
23 git update-ref refs/heads/svn-HEAD refs/${remotes_git_svn} &&
24 git update-ref -d refs/${remotes_git_svn} refs/${remotes_git_svn}
f69e836f 25 '
706587fc
EW
26
27head=`git rev-parse --verify refs/heads/git-svn-HEAD^0`
28test_expect_success 'git-svn-HEAD is a real HEAD' "test -n '$head'"
29
93c3fcbe
MS
30svnrepo_escaped=`echo $svnrepo | sed 's/ /%20/'`
31
1364ff27 32test_expect_success 'initialize old-style (v0) git svn layout' '
f69e836f
BD
33 mkdir -p "$GIT_DIR"/git-svn/info "$GIT_DIR"/svn/info &&
34 echo "$svnrepo" > "$GIT_DIR"/git-svn/info/url &&
35 echo "$svnrepo" > "$GIT_DIR"/svn/info/url &&
1364ff27 36 git svn migrate &&
1a35da0b 37 ! test -d "$GIT_DIR"/git-svn &&
16805d3e 38 git rev-parse --verify refs/${remotes_git_svn}^0 &&
5be60078 39 git rev-parse --verify refs/remotes/svn^0 &&
93c3fcbe 40 test "$(git config --get svn-remote.svn.url)" = "$svnrepo_escaped" &&
f69e836f 41 test `git config --get svn-remote.svn.fetch` = \
16805d3e 42 ":refs/${remotes_git_svn}"
f69e836f 43 '
706587fc 44
f69e836f 45test_expect_success 'initialize a multi-repository repo' '
1364ff27 46 git svn init "$svnrepo" -T trunk -t tags -b branches &&
5be60078 47 git config --get-all svn-remote.svn.fetch > fetch.out &&
f69e836f
BD
48 grep "^trunk:refs/remotes/trunk$" fetch.out &&
49 test -n "`git config --get svn-remote.svn.branches \
50 "^branches/\*:refs/remotes/\*$"`" &&
51 test -n "`git config --get svn-remote.svn.tags \
52 "^tags/\*:refs/remotes/tags/\*$"`" &&
4bb9ed04 53 git config --unset svn-remote.svn.branches \
f69e836f 54 "^branches/\*:refs/remotes/\*$" &&
4bb9ed04 55 git config --unset svn-remote.svn.tags \
f69e836f
BD
56 "^tags/\*:refs/remotes/tags/\*$" &&
57 git config --add svn-remote.svn.fetch "branches/a:refs/remotes/a" &&
58 git config --add svn-remote.svn.fetch "branches/b:refs/remotes/b" &&
4bb9ed04 59 for i in tags/0.1 tags/0.2 tags/0.3; do
5be60078 60 git config --add svn-remote.svn.fetch \
4ebe6e92
AB
61 $i:refs/remotes/$i || exit 1; done &&
62 git config --get-all svn-remote.svn.fetch > fetch.out &&
63 grep "^trunk:refs/remotes/trunk$" fetch.out &&
64 grep "^branches/a:refs/remotes/a$" fetch.out &&
65 grep "^branches/b:refs/remotes/b$" fetch.out &&
66 grep "^tags/0\.1:refs/remotes/tags/0\.1$" fetch.out &&
67 grep "^tags/0\.2:refs/remotes/tags/0\.2$" fetch.out &&
68 grep "^tags/0\.3:refs/remotes/tags/0\.3$" fetch.out &&
69 grep "^:refs/${remotes_git_svn}" fetch.out
f69e836f 70 '
706587fc 71
47e39c55 72# refs should all be different, but the trees should all be the same:
706587fc 73test_expect_success 'multi-fetch works on partial urls + paths' "
1364ff27 74 git svn multi-fetch &&
706587fc
EW
75 for i in trunk a b tags/0.1 tags/0.2 tags/0.3; do
76 git rev-parse --verify refs/remotes/\$i^0 >> refs.out || exit 1;
77 done &&
78 test -z \"\`sort < refs.out | uniq -d\`\" &&
79 for i in trunk a b tags/0.1 tags/0.2 tags/0.3; do
80 for j in trunk a b tags/0.1 tags/0.2 tags/0.3; do
81 if test \$j != \$i; then continue; fi
82 test -z \"\`git diff refs/remotes/\$i \
83 refs/remotes/\$j\`\" ||exit 1; done; done
84 "
85
f69e836f 86test_expect_success 'migrate --minimize on old inited layout' '
ccb6b6f5
EW
87 git config --unset-all svn-remote.svn.fetch &&
88 git config --unset-all svn-remote.svn.url &&
f69e836f
BD
89 rm -rf "$GIT_DIR"/svn &&
90 for i in `cat fetch.out`; do
91 path=`expr $i : "\([^:]*\):.*$"`
6f5748e1 92 ref=`expr $i : "[^:]*:\(refs/remotes/.*\)$"`
f69e836f
BD
93 if test -z "$ref"; then continue; fi
94 if test -n "$path"; then path="/$path"; fi
95 ( mkdir -p "$GIT_DIR"/svn/$ref/info/ &&
96 echo "$svnrepo"$path > "$GIT_DIR"/svn/$ref/info/url ) || exit 1;
47e39c55 97 done &&
1364ff27 98 git svn migrate --minimize &&
4ebe6e92 99 test -z "`git config -l | grep "^svn-remote\.git-svn\."`" &&
5be60078 100 git config --get-all svn-remote.svn.fetch > fetch.out &&
f69e836f
BD
101 grep "^trunk:refs/remotes/trunk$" fetch.out &&
102 grep "^branches/a:refs/remotes/a$" fetch.out &&
103 grep "^branches/b:refs/remotes/b$" fetch.out &&
104 grep "^tags/0\.1:refs/remotes/tags/0\.1$" fetch.out &&
105 grep "^tags/0\.2:refs/remotes/tags/0\.2$" fetch.out &&
4ebe6e92 106 grep "^tags/0\.3:refs/remotes/tags/0\.3$" fetch.out &&
16805d3e 107 grep "^:refs/${remotes_git_svn}" fetch.out
f69e836f 108 '
47e39c55 109
f69e836f 110test_expect_success ".rev_db auto-converted to .rev_map.UUID" '
1364ff27 111 git svn fetch -i trunk &&
6f5748e1
AB
112 test -z "$(ls "$GIT_DIR"/svn/refs/remotes/trunk/.rev_db.* 2>/dev/null)" &&
113 expect="$(ls "$GIT_DIR"/svn/refs/remotes/trunk/.rev_map.*)" &&
f69e836f
BD
114 test -n "$expect" &&
115 rev_db="$(echo $expect | sed -e "s,_map,_db,")" &&
116 convert_to_rev_db "$expect" "$rev_db" &&
117 rm -f "$expect" &&
118 test -f "$rev_db" &&
1364ff27 119 git svn fetch -i trunk &&
6f5748e1
AB
120 test -z "$(ls "$GIT_DIR"/svn/refs/remotes/trunk/.rev_db.* 2>/dev/null)" &&
121 test ! -e "$GIT_DIR"/svn/refs/remotes/trunk/.rev_db &&
f69e836f
BD
122 test -f "$expect"
123 '
26a62d57 124
706587fc 125test_done