diff: convert struct combine_diff_path to object_id
[alt-git.git] / t / t9107-git-svn-migrate.sh
blob6e69fc4c65aeb77b1a4d784c7842762090ae6787
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 mkdir import &&
10 cd import &&
11 for i in trunk branches/a branches/b tags/0.1 tags/0.2 tags/0.3
13 mkdir -p $i &&
14 echo hello >>$i/README ||
15 exit 1
16 done &&
17 svn_cmd import -m test . "$svnrepo"
18 ) &&
19 git svn init "$svnrepo" &&
20 git svn fetch &&
21 rm -rf "$GIT_DIR"/svn &&
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}
27 head=`git rev-parse --verify refs/heads/git-svn-HEAD^0`
28 test_expect_success 'git-svn-HEAD is a real HEAD' "test -n '$head'"
30 svnrepo_escaped=`echo $svnrepo | sed 's/ /%20/'`
32 test_expect_success 'initialize old-style (v0) git svn layout' '
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 &&
36 git svn migrate &&
37 ! test -d "$GIT_DIR"/git-svn &&
38 git rev-parse --verify refs/${remotes_git_svn}^0 &&
39 git rev-parse --verify refs/remotes/svn^0 &&
40 test "$(git config --get svn-remote.svn.url)" = "$svnrepo_escaped" &&
41 test `git config --get svn-remote.svn.fetch` = \
42 ":refs/${remotes_git_svn}"
45 test_expect_success 'initialize a multi-repository repo' '
46 git svn init "$svnrepo" -T trunk -t tags -b branches &&
47 git config --get-all svn-remote.svn.fetch > fetch.out &&
48 grep "^trunk:refs/remotes/origin/trunk$" fetch.out &&
49 test -n "`git config --get svn-remote.svn.branches \
50 "^branches/\*:refs/remotes/origin/\*$"`" &&
51 test -n "`git config --get svn-remote.svn.tags \
52 "^tags/\*:refs/remotes/origin/tags/\*$"`" &&
53 git config --unset svn-remote.svn.branches \
54 "^branches/\*:refs/remotes/origin/\*$" &&
55 git config --unset svn-remote.svn.tags \
56 "^tags/\*:refs/remotes/origin/tags/\*$" &&
57 git config --add svn-remote.svn.fetch "branches/a:refs/remotes/origin/a" &&
58 git config --add svn-remote.svn.fetch "branches/b:refs/remotes/origin/b" &&
59 for i in tags/0.1 tags/0.2 tags/0.3; do
60 git config --add svn-remote.svn.fetch \
61 $i:refs/remotes/origin/$i || exit 1; done &&
62 git config --get-all svn-remote.svn.fetch > fetch.out &&
63 grep "^trunk:refs/remotes/origin/trunk$" fetch.out &&
64 grep "^branches/a:refs/remotes/origin/a$" fetch.out &&
65 grep "^branches/b:refs/remotes/origin/b$" fetch.out &&
66 grep "^tags/0\.1:refs/remotes/origin/tags/0\.1$" fetch.out &&
67 grep "^tags/0\.2:refs/remotes/origin/tags/0\.2$" fetch.out &&
68 grep "^tags/0\.3:refs/remotes/origin/tags/0\.3$" fetch.out &&
69 grep "^:refs/${remotes_git_svn}" fetch.out
72 # refs should all be different, but the trees should all be the same:
73 test_expect_success 'multi-fetch works on partial urls + paths' "
74 git svn multi-fetch &&
75 for i in trunk a b tags/0.1 tags/0.2 tags/0.3; do
76 git rev-parse --verify refs/remotes/origin/\$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/origin/\$i \
83 refs/remotes/origin/\$j\`\" ||exit 1; done; done
86 test_expect_success 'migrate --minimize on old inited layout' '
87 git config --unset-all svn-remote.svn.fetch &&
88 git config --unset-all svn-remote.svn.url &&
89 rm -rf "$GIT_DIR"/svn &&
90 for i in `cat fetch.out`; do
91 path=`expr $i : "\([^:]*\):.*$"`
92 ref=`expr $i : "[^:]*:\(refs/remotes/.*\)$"`
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;
97 done &&
98 git svn migrate --minimize &&
99 test -z "`git config -l | grep "^svn-remote\.git-svn\."`" &&
100 git config --get-all svn-remote.svn.fetch > fetch.out &&
101 grep "^trunk:refs/remotes/origin/trunk$" fetch.out &&
102 grep "^branches/a:refs/remotes/origin/a$" fetch.out &&
103 grep "^branches/b:refs/remotes/origin/b$" fetch.out &&
104 grep "^tags/0\.1:refs/remotes/origin/tags/0\.1$" fetch.out &&
105 grep "^tags/0\.2:refs/remotes/origin/tags/0\.2$" fetch.out &&
106 grep "^tags/0\.3:refs/remotes/origin/tags/0\.3$" fetch.out &&
107 grep "^:refs/${remotes_git_svn}" fetch.out
110 test_expect_success ".rev_db auto-converted to .rev_map.UUID" '
111 git svn fetch -i trunk &&
112 test -z "$(ls "$GIT_DIR"/svn/refs/remotes/origin/trunk/.rev_db.* 2>/dev/null)" &&
113 expect="$(ls "$GIT_DIR"/svn/refs/remotes/origin/trunk/.rev_map.*)" &&
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" &&
119 git svn fetch -i trunk &&
120 test -z "$(ls "$GIT_DIR"/svn/refs/remotes/origin/trunk/.rev_db.* 2>/dev/null)" &&
121 test ! -e "$GIT_DIR"/svn/refs/remotes/origin/trunk/.rev_db &&
122 test -f "$expect"
125 test_done