Git 2.45
[git/gitster.git] / t / t9117-git-svn-init-clone.sh
blob3b038c338f2154e4470d3f472a448d5881adf54d
1 #!/bin/sh
3 # Copyright (c) 2007 Eric Wong
6 test_description='git svn init/clone tests'
8 . ./lib-git-svn.sh
10 test_expect_success 'setup svnrepo' '
11 mkdir project project/trunk project/branches project/tags &&
12 echo foo > project/trunk/foo &&
13 svn_cmd import -m "$test_description" project "$svnrepo"/project &&
14 rm -rf project
17 test_expect_success 'basic clone' '
18 test ! -d trunk &&
19 git svn clone "$svnrepo"/project/trunk &&
20 test_path_is_dir trunk/.git/svn &&
21 test_path_exists trunk/foo &&
22 rm -rf trunk
25 test_expect_success 'clone to target directory' '
26 test ! -d target &&
27 git svn clone "$svnrepo"/project/trunk target &&
28 test_path_is_dir target/.git/svn &&
29 test_path_exists target/foo &&
30 rm -rf target
33 test_expect_success 'clone with --stdlayout' '
34 test ! -d project &&
35 git svn clone -s "$svnrepo"/project &&
36 test_path_is_dir project/.git/svn &&
37 test_path_exists project/foo &&
38 rm -rf project
41 test_expect_success 'clone to target directory with --stdlayout' '
42 test ! -d target &&
43 git svn clone -s "$svnrepo"/project target &&
44 test_path_is_dir target/.git/svn &&
45 test_path_exists target/foo &&
46 rm -rf target
49 test_expect_success 'init without -s/-T/-b/-t does not warn' '
50 test ! -d trunk &&
51 git svn init "$svnrepo"/project/trunk trunk 2>warning &&
52 ! grep -q prefix warning &&
53 rm -rf trunk &&
54 rm -f warning
57 test_expect_success 'clone without -s/-T/-b/-t does not warn' '
58 test ! -d trunk &&
59 git svn clone "$svnrepo"/project/trunk 2>warning &&
60 ! grep -q prefix warning &&
61 rm -rf trunk &&
62 rm -f warning
65 test_svn_configured_prefix () {
66 prefix=$1 &&
67 cat >expect <<EOF &&
68 project/trunk:refs/remotes/${prefix}trunk
69 project/branches/*:refs/remotes/${prefix}*
70 project/tags/*:refs/remotes/${prefix}tags/*
71 EOF
72 test ! -f actual &&
73 git --git-dir=project/.git config svn-remote.svn.fetch >>actual &&
74 git --git-dir=project/.git config svn-remote.svn.branches >>actual &&
75 git --git-dir=project/.git config svn-remote.svn.tags >>actual &&
76 test_cmp expect actual &&
77 rm -f expect actual
80 test_expect_success 'init with -s/-T/-b/-t assumes --prefix=origin/' '
81 test ! -d project &&
82 git svn init -s "$svnrepo"/project project 2>warning &&
83 ! grep -q prefix warning &&
84 test_svn_configured_prefix "origin/" &&
85 rm -rf project &&
86 rm -f warning
89 test_expect_success 'clone with -s/-T/-b/-t assumes --prefix=origin/' '
90 test ! -d project &&
91 git svn clone -s "$svnrepo"/project 2>warning &&
92 ! grep -q prefix warning &&
93 test_svn_configured_prefix "origin/" &&
94 rm -rf project &&
95 rm -f warning
98 test_expect_success 'init with -s/-T/-b/-t and --prefix "" still works' '
99 test ! -d project &&
100 git svn init -s "$svnrepo"/project project --prefix "" 2>warning &&
101 ! grep -q prefix warning &&
102 test_svn_configured_prefix "" &&
103 rm -rf project &&
104 rm -f warning
107 test_expect_success 'clone with -s/-T/-b/-t and --prefix "" still works' '
108 test ! -d project &&
109 git svn clone -s "$svnrepo"/project --prefix "" 2>warning &&
110 ! grep -q prefix warning &&
111 test_svn_configured_prefix "" &&
112 rm -rf project &&
113 rm -f warning
116 test_expect_success 'init with -T as a full url works' '
117 test ! -d project &&
118 git svn init -T "$svnrepo"/project/trunk project &&
119 rm -rf project
122 test_done