1#!/bin/sh
2test_description='git-svn graft-branches'
3. ./lib-git-svn.sh
4
5svnrepo="$svnrepo/test-git-svn"
6
7test_expect_success 'initialize repo' "
8 mkdir import &&
9 cd import &&
10 mkdir -p trunk branches tags &&
11 echo hello > trunk/readme &&
12 svn import -m 'import for git-svn' . $svnrepo &&
13 cd .. &&
14 svn cp -m 'tag a' $svnrepo/trunk $svnrepo/tags/a &&
15 svn cp -m 'branch a' $svnrepo/trunk $svnrepo/branches/a &&
16 svn co $svnrepo wc &&
17 cd wc &&
18 echo feedme >> branches/a/readme &&
19 poke branches/a/readme &&
20 svn commit -m hungry &&
21 cd trunk &&
22 svn merge -r3:4 $svnrepo/branches/a &&
23 svn commit -m 'merge with a' &&
24 cd ../.. &&
25 git-svn multi-init $svnrepo -T trunk -b branches -t tags &&
26 git-svn multi-fetch
27 "
28
29test_expect_success 'multi-init set .git/config correctly' "
30 test '$svnrepo/trunk' = '`git repo-config --get svn.trunk`' &&
31 test '$svnrepo/branches' = '`git repo-config --get svn.branches`' &&
32 test '$svnrepo/tags' = '`git repo-config --get svn.tags`'
33 "
34
35r1=`git-rev-list remotes/trunk | tail -n1`
36r2=`git-rev-list remotes/tags/a | tail -n1`
37r3=`git-rev-list remotes/a | tail -n1`
38r4=`git-rev-parse remotes/a`
39r5=`git-rev-parse remotes/trunk`
40
41test_expect_success 'test graft-branches regexes and copies' "
42 test -n "$r1" &&
43 test -n "$r2" &&
44 test -n "$r3" &&
45 test -n "$r4" &&
46 test -n "$r5" &&
47 git-svn graft-branches &&
48 grep '^$r2 $r1' $GIT_DIR/info/grafts &&
49 grep '^$r3 $r1' $GIT_DIR/info/grafts &&
50 grep '^$r5 ' $GIT_DIR/info/grafts | grep '$r4' | grep '$r1'
51 "
52
53test_debug 'gitk --all & sleep 1'
54
55test_expect_success 'test graft-branches with tree-joins' "
56 rm $GIT_DIR/info/grafts &&
57 git-svn graft-branches --no-default-regex --no-graft-copy -B &&
58 grep '^$r3 ' $GIT_DIR/info/grafts | grep '$r1' | grep '$r2' &&
59 grep '^$r2 $r1' $GIT_DIR/info/grafts &&
60 grep '^$r5 ' $GIT_DIR/info/grafts | grep '$r1' | grep '$r4'
61 "
62
63# the result of this is kinda funky, we have a strange history and
64# this is just a test :)
65test_debug 'gitk --all &'
66
67test_done