]>
Commit | Line | Data |
---|---|---|
41337e22 EW |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2007 Eric Wong | |
4 | # | |
5 | ||
1364ff27 | 6 | test_description='git svn init/clone tests' |
41337e22 EW |
7 | |
8 | . ./lib-git-svn.sh | |
9 | ||
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 | |
15 | ||
f69e836f | 16 | test_expect_success 'setup svnrepo' ' |
41337e22 EW |
17 | mkdir project project/trunk project/branches project/tags && |
18 | echo foo > project/trunk/foo && | |
da083d68 | 19 | svn_cmd import -m "$test_description" project "$svnrepo"/project && |
41337e22 | 20 | rm -rf project |
f69e836f | 21 | ' |
41337e22 | 22 | |
f69e836f | 23 | test_expect_success 'basic clone' ' |
41337e22 | 24 | test ! -d trunk && |
f69e836f | 25 | git svn clone "$svnrepo"/project/trunk && |
41337e22 EW |
26 | test -d trunk/.git/svn && |
27 | test -e trunk/foo && | |
28 | rm -rf trunk | |
f69e836f | 29 | ' |
41337e22 | 30 | |
f69e836f | 31 | test_expect_success 'clone to target directory' ' |
41337e22 | 32 | test ! -d target && |
f69e836f | 33 | git svn clone "$svnrepo"/project/trunk target && |
41337e22 EW |
34 | test -d target/.git/svn && |
35 | test -e target/foo && | |
36 | rm -rf target | |
f69e836f | 37 | ' |
41337e22 | 38 | |
f69e836f | 39 | test_expect_success 'clone with --stdlayout' ' |
41337e22 | 40 | test ! -d project && |
f69e836f | 41 | git svn clone -s "$svnrepo"/project && |
41337e22 EW |
42 | test -d project/.git/svn && |
43 | test -e project/foo && | |
44 | rm -rf project | |
f69e836f | 45 | ' |
41337e22 | 46 | |
f69e836f | 47 | test_expect_success 'clone to target directory with --stdlayout' ' |
41337e22 | 48 | test ! -d target && |
f69e836f | 49 | git svn clone -s "$svnrepo"/project target && |
41337e22 EW |
50 | test -d target/.git/svn && |
51 | test -e target/foo && | |
52 | rm -rf target | |
f69e836f | 53 | ' |
41337e22 | 54 | |
f849bb6b JH |
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 && | |
c7cf9566 | 58 | ! grep -q prefix warning && |
f849bb6b JH |
59 | rm -rf trunk && |
60 | rm -f warning | |
61 | ' | |
62 | ||
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 && | |
c7cf9566 | 66 | ! grep -q prefix warning && |
f849bb6b JH |
67 | rm -rf trunk && |
68 | rm -f warning | |
69 | ' | |
70 | ||
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 | |
84 | } | |
85 | ||
fe191fca | 86 | test_expect_success 'init with -s/-T/-b/-t assumes --prefix=origin/' ' |
f849bb6b JH |
87 | test ! -d project && |
88 | git svn init -s "$svnrepo"/project project 2>warning && | |
c7cf9566 | 89 | ! grep -q prefix warning && |
fe191fca | 90 | test_svn_configured_prefix "origin/" && |
f849bb6b JH |
91 | rm -rf project && |
92 | rm -f warning | |
93 | ' | |
94 | ||
fe191fca | 95 | test_expect_success 'clone with -s/-T/-b/-t assumes --prefix=origin/' ' |
f849bb6b JH |
96 | test ! -d project && |
97 | git svn clone -s "$svnrepo"/project 2>warning && | |
c7cf9566 | 98 | ! grep -q prefix warning && |
fe191fca | 99 | test_svn_configured_prefix "origin/" && |
f849bb6b JH |
100 | rm -rf project && |
101 | rm -f warning | |
102 | ' | |
103 | ||
7bbc458b | 104 | test_expect_success 'init with -s/-T/-b/-t and --prefix "" still works' ' |
f849bb6b | 105 | test ! -d project && |
7bbc458b | 106 | git svn init -s "$svnrepo"/project project --prefix "" 2>warning && |
c7cf9566 | 107 | ! grep -q prefix warning && |
f849bb6b JH |
108 | test_svn_configured_prefix "" && |
109 | rm -rf project && | |
110 | rm -f warning | |
111 | ' | |
112 | ||
7bbc458b | 113 | test_expect_success 'clone with -s/-T/-b/-t and --prefix "" still works' ' |
f849bb6b | 114 | test ! -d project && |
7bbc458b | 115 | git svn clone -s "$svnrepo"/project --prefix "" 2>warning && |
c7cf9566 | 116 | ! grep -q prefix warning && |
f849bb6b JH |
117 | test_svn_configured_prefix "" && |
118 | rm -rf project && | |
119 | rm -f warning | |
120 | ' | |
121 | ||
b5571653 | 122 | test_expect_success 'init with -T as a full url works' ' |
4be4d550 AD |
123 | test ! -d project && |
124 | git svn init -T "$svnrepo"/project/trunk project && | |
125 | rm -rf project | |
126 | ' | |
127 | ||
41337e22 | 128 | test_done |