]> git.ipfire.org Git - thirdparty/git.git/blame - t/t9117-git-svn-init-clone.sh
Sync with Git 2.45.1
[thirdparty/git.git] / t / t9117-git-svn-init-clone.sh
CommitLineData
41337e22
EW
1#!/bin/sh
2#
3# Copyright (c) 2007 Eric Wong
4#
5
1364ff27 6test_description='git svn init/clone tests'
41337e22
EW
7
8. ./lib-git-svn.sh
9
f69e836f 10test_expect_success 'setup svnrepo' '
41337e22
EW
11 mkdir project project/trunk project/branches project/tags &&
12 echo foo > project/trunk/foo &&
da083d68 13 svn_cmd import -m "$test_description" project "$svnrepo"/project &&
41337e22 14 rm -rf project
f69e836f 15 '
41337e22 16
f69e836f 17test_expect_success 'basic clone' '
41337e22 18 test ! -d trunk &&
f69e836f 19 git svn clone "$svnrepo"/project/trunk &&
0332e813 20 test_path_is_dir trunk/.git/svn &&
21 test_path_exists trunk/foo &&
41337e22 22 rm -rf trunk
f69e836f 23 '
41337e22 24
f69e836f 25test_expect_success 'clone to target directory' '
41337e22 26 test ! -d target &&
f69e836f 27 git svn clone "$svnrepo"/project/trunk target &&
0332e813 28 test_path_is_dir target/.git/svn &&
29 test_path_exists target/foo &&
41337e22 30 rm -rf target
f69e836f 31 '
41337e22 32
f69e836f 33test_expect_success 'clone with --stdlayout' '
41337e22 34 test ! -d project &&
f69e836f 35 git svn clone -s "$svnrepo"/project &&
0332e813 36 test_path_is_dir project/.git/svn &&
37 test_path_exists project/foo &&
41337e22 38 rm -rf project
f69e836f 39 '
41337e22 40
f69e836f 41test_expect_success 'clone to target directory with --stdlayout' '
41337e22 42 test ! -d target &&
f69e836f 43 git svn clone -s "$svnrepo"/project target &&
0332e813 44 test_path_is_dir target/.git/svn &&
45 test_path_exists target/foo &&
41337e22 46 rm -rf target
f69e836f 47 '
41337e22 48
f849bb6b
JH
49test_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 &&
c7cf9566 52 ! grep -q prefix warning &&
f849bb6b
JH
53 rm -rf trunk &&
54 rm -f warning
55 '
56
57test_expect_success 'clone without -s/-T/-b/-t does not warn' '
58 test ! -d trunk &&
59 git svn clone "$svnrepo"/project/trunk 2>warning &&
c7cf9566 60 ! grep -q prefix warning &&
f849bb6b
JH
61 rm -rf trunk &&
62 rm -f warning
63 '
64
65test_svn_configured_prefix () {
66 prefix=$1 &&
67 cat >expect <<EOF &&
68project/trunk:refs/remotes/${prefix}trunk
69project/branches/*:refs/remotes/${prefix}*
70project/tags/*:refs/remotes/${prefix}tags/*
71EOF
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
78}
79
fe191fca 80test_expect_success 'init with -s/-T/-b/-t assumes --prefix=origin/' '
f849bb6b
JH
81 test ! -d project &&
82 git svn init -s "$svnrepo"/project project 2>warning &&
c7cf9566 83 ! grep -q prefix warning &&
fe191fca 84 test_svn_configured_prefix "origin/" &&
f849bb6b
JH
85 rm -rf project &&
86 rm -f warning
87 '
88
fe191fca 89test_expect_success 'clone with -s/-T/-b/-t assumes --prefix=origin/' '
f849bb6b
JH
90 test ! -d project &&
91 git svn clone -s "$svnrepo"/project 2>warning &&
c7cf9566 92 ! grep -q prefix warning &&
fe191fca 93 test_svn_configured_prefix "origin/" &&
f849bb6b
JH
94 rm -rf project &&
95 rm -f warning
96 '
97
7bbc458b 98test_expect_success 'init with -s/-T/-b/-t and --prefix "" still works' '
f849bb6b 99 test ! -d project &&
7bbc458b 100 git svn init -s "$svnrepo"/project project --prefix "" 2>warning &&
c7cf9566 101 ! grep -q prefix warning &&
f849bb6b
JH
102 test_svn_configured_prefix "" &&
103 rm -rf project &&
104 rm -f warning
105 '
106
7bbc458b 107test_expect_success 'clone with -s/-T/-b/-t and --prefix "" still works' '
f849bb6b 108 test ! -d project &&
7bbc458b 109 git svn clone -s "$svnrepo"/project --prefix "" 2>warning &&
c7cf9566 110 ! grep -q prefix warning &&
f849bb6b
JH
111 test_svn_configured_prefix "" &&
112 rm -rf project &&
113 rm -f warning
114 '
115
b5571653 116test_expect_success 'init with -T as a full url works' '
4be4d550
AD
117 test ! -d project &&
118 git svn init -T "$svnrepo"/project/trunk project &&
119 rm -rf project
120 '
121
41337e22 122test_done