Merge branch 'yk/git-tag-remove-mention-of-old-layout-in-doc' into maint
[git] / t / t9020-remote-svn.sh
1 #!/bin/sh
2
3 test_description='tests remote-svn'
4
5 . ./test-lib.sh
6
7 MARKSPATH=.git/info/fast-import/remote-svn
8
9 if ! test_have_prereq PYTHON
10 then
11         skip_all='skipping remote-svn tests, python not available'
12         test_done
13 fi
14
15 # Override svnrdump with our simulator
16 PATH="$HOME:$PATH"
17 export PATH PYTHON_PATH GIT_BUILD_DIR
18
19 write_script "$HOME/svnrdump" <<\EOF
20 exec "$PYTHON_PATH" "$GIT_BUILD_DIR/contrib/svn-fe/svnrdump_sim.py" "$@"
21 EOF
22
23 init_git () {
24         rm -fr .git &&
25         git init &&
26         #git remote add svnsim testsvn::sim:///$TEST_DIRECTORY/t9020/example.svnrdump
27         # let's reuse an existing dump file!?
28         git remote add svnsim testsvn::sim://$TEST_DIRECTORY/t9154/svn.dump
29         git remote add svnfile testsvn::file://$TEST_DIRECTORY/t9154/svn.dump
30 }
31
32 if test -e "$GIT_BUILD_DIR/git-remote-testsvn"
33 then
34         test_set_prereq REMOTE_SVN
35 fi
36
37 test_debug '
38         git --version
39         type git
40         type svnrdump
41 '
42
43 test_expect_success REMOTE_SVN 'simple fetch' '
44         init_git &&
45         git fetch svnsim &&
46         test_cmp .git/refs/svn/svnsim/master .git/refs/remotes/svnsim/master  &&
47         cp .git/refs/remotes/svnsim/master master.good
48 '
49
50 test_debug '
51         cat .git/refs/svn/svnsim/master
52         cat .git/refs/remotes/svnsim/master
53 '
54
55 test_expect_success REMOTE_SVN 'repeated fetch, nothing shall change' '
56         git fetch svnsim &&
57         test_cmp master.good .git/refs/remotes/svnsim/master
58 '
59
60 test_expect_success REMOTE_SVN 'fetch from a file:// url gives the same result' '
61         git fetch svnfile
62 '
63
64 test_expect_failure REMOTE_SVN 'the sha1 differ because the git-svn-id line in the commit msg contains the url' '
65         test_cmp .git/refs/remotes/svnfile/master .git/refs/remotes/svnsim/master
66 '
67
68 test_expect_success REMOTE_SVN 'mark-file regeneration' '
69         # filter out any other marks, that can not be regenerated. Only up to 3 digit revisions are allowed here
70         grep ":[0-9]\{1,3\} " $MARKSPATH/svnsim.marks > $MARKSPATH/svnsim.marks.old &&
71         rm $MARKSPATH/svnsim.marks &&
72         git fetch svnsim &&
73         test_cmp $MARKSPATH/svnsim.marks.old $MARKSPATH/svnsim.marks
74 '
75
76 test_expect_success REMOTE_SVN 'incremental imports must lead to the same head' '
77         SVNRMAX=3 &&
78         export SVNRMAX &&
79         init_git &&
80         git fetch svnsim &&
81         test_cmp .git/refs/svn/svnsim/master .git/refs/remotes/svnsim/master  &&
82         unset SVNRMAX &&
83         git fetch svnsim &&
84         test_cmp master.good .git/refs/remotes/svnsim/master
85 '
86
87 test_debug 'git branch -a'
88
89 test_done