Merge branch 'oh/fix-config-default-user-name-section' into maint-2.3
[alt-git.git] / t / t9117-git-svn-init-clone.sh
bloba66f43c6b1a2d9194f87a17e1758f24018cf8b1b
1 #!/bin/sh
3 # Copyright (c) 2007 Eric Wong
6 test_description='git svn init/clone tests'
8 . ./lib-git-svn.sh
10 # setup, run inside tmp so we don't have any conflicts with $svnrepo
11 set -e
12 rm -r .git
13 mkdir tmp
14 cd tmp
16 test_expect_success 'setup svnrepo' '
17 mkdir project project/trunk project/branches project/tags &&
18 echo foo > project/trunk/foo &&
19 svn_cmd import -m "$test_description" project "$svnrepo"/project &&
20 rm -rf project
23 test_expect_success 'basic clone' '
24 test ! -d trunk &&
25 git svn clone "$svnrepo"/project/trunk &&
26 test -d trunk/.git/svn &&
27 test -e trunk/foo &&
28 rm -rf trunk
31 test_expect_success 'clone to target directory' '
32 test ! -d target &&
33 git svn clone "$svnrepo"/project/trunk target &&
34 test -d target/.git/svn &&
35 test -e target/foo &&
36 rm -rf target
39 test_expect_success 'clone with --stdlayout' '
40 test ! -d project &&
41 git svn clone -s "$svnrepo"/project &&
42 test -d project/.git/svn &&
43 test -e project/foo &&
44 rm -rf project
47 test_expect_success 'clone to target directory with --stdlayout' '
48 test ! -d target &&
49 git svn clone -s "$svnrepo"/project target &&
50 test -d target/.git/svn &&
51 test -e target/foo &&
52 rm -rf target
55 test_expect_success 'init without -s/-T/-b/-t does not warn' '
56 test ! -d trunk &&
57 git svn init "$svnrepo"/project/trunk trunk 2>warning &&
58 test_must_fail grep -q prefix warning &&
59 rm -rf trunk &&
60 rm -f warning
63 test_expect_success 'clone without -s/-T/-b/-t does not warn' '
64 test ! -d trunk &&
65 git svn clone "$svnrepo"/project/trunk 2>warning &&
66 test_must_fail grep -q prefix warning &&
67 rm -rf trunk &&
68 rm -f warning
71 test_svn_configured_prefix () {
72 prefix=$1 &&
73 cat >expect <<EOF &&
74 project/trunk:refs/remotes/${prefix}trunk
75 project/branches/*:refs/remotes/${prefix}*
76 project/tags/*:refs/remotes/${prefix}tags/*
77 EOF
78 test ! -f actual &&
79 git --git-dir=project/.git config svn-remote.svn.fetch >>actual &&
80 git --git-dir=project/.git config svn-remote.svn.branches >>actual &&
81 git --git-dir=project/.git config svn-remote.svn.tags >>actual &&
82 test_cmp expect actual &&
83 rm -f expect actual
86 test_expect_success 'init with -s/-T/-b/-t assumes --prefix=origin/' '
87 test ! -d project &&
88 git svn init -s "$svnrepo"/project project 2>warning &&
89 test_must_fail grep -q prefix warning &&
90 test_svn_configured_prefix "origin/" &&
91 rm -rf project &&
92 rm -f warning
95 test_expect_success 'clone with -s/-T/-b/-t assumes --prefix=origin/' '
96 test ! -d project &&
97 git svn clone -s "$svnrepo"/project 2>warning &&
98 test_must_fail grep -q prefix warning &&
99 test_svn_configured_prefix "origin/" &&
100 rm -rf project &&
101 rm -f warning
104 test_expect_success 'init with -s/-T/-b/-t and --prefix "" still works' '
105 test ! -d project &&
106 git svn init -s "$svnrepo"/project project --prefix "" 2>warning &&
107 test_must_fail grep -q prefix warning &&
108 test_svn_configured_prefix "" &&
109 rm -rf project &&
110 rm -f warning
113 test_expect_success 'clone with -s/-T/-b/-t and --prefix "" still works' '
114 test ! -d project &&
115 git svn clone -s "$svnrepo"/project --prefix "" 2>warning &&
116 test_must_fail grep -q prefix warning &&
117 test_svn_configured_prefix "" &&
118 rm -rf project &&
119 rm -f warning
122 test_done