git-svn: Warn about changing default for --prefix in Git v2.0
In Git v2.0, we will change the default --prefix for init/clone from none/empty to "origin/" (which causes SVN-tracking branches to be placed at refs/remotes/origin/* instead of refs/remotes/*). This patch warns users about the upcoming change, both in the git-svn manual page, and on stderr when running init/clone in the "multi-mode" without providing a --prefix. Cc: Eric Wong <normalperson@yhbt.net> Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Eric Wong <normalperson@yhbt.net>
Johan Herland committed
Oct 11, 2013 at 14:57 UTC
f849bb6b3b4ccc7cc1a68f49d6ff1e9c508fdf17
3 files changed
+88
-2
Documentation/git-svn.txt
+10
-1
@@ -86,6 +86,14 @@ COMMANDS
86
(refs/remotes/$remote/*). Setting a prefix is also useful
87
if you wish to track multiple projects that share a common
88
repository.
89
++
90
+NOTE: In Git v2.0, the default prefix will CHANGE from "" (no prefix)
91
+to "origin/". This is done to put SVN-tracking refs at
92
+"refs/remotes/origin/*" instead of "refs/remotes/*", and make them
93
+more compatible with how Git's own remote-tracking refs are organized
94
+(i.e. refs/remotes/$remote/*). You can enjoy the same benefits today,
95
+by using the --prefix option.
96
+
97
--ignore-paths=<regex>;;
98
When passed to 'init' or 'clone' this regular expression will
99
be preserved as a config key. See 'fetch' for a description
@@ -993,7 +1001,8 @@ placed at refs/remotes/origin/* rather than the default refs/remotes/*.
1001
The former is more compatible with the layout of Git's "regular"
1002
remote-tracking refs (refs/remotes/$remote/*), and may potentially
1003
prevent similarly named SVN branches and Git remotes from clobbering
996
-each other.
1004
+each other. In Git v2.0 the default prefix used (i.e. when no --prefix
1005
+is given) will change from "" (no prefix) to "origin/".
1006
1007
When using multiple --branches or --tags, 'git svn' does not automatically
1008
handle name collisions (for example, if two branches from different paths have
git-svn.perl
+11
-1
@@ -1389,7 +1389,17 @@ sub cmd_multi_init {
1389
usage(1);
1390
}
1391
1392
- $_prefix = '' unless defined $_prefix;
1392
+ unless (defined $_prefix) {
1393
+ $_prefix = '';
1394
+ warn <<EOF
1395
+WARNING: --prefix is not given, defaulting to empty prefix.
1396
+ This is probably not what you want! In order to stay compatible
1397
+ with regular remote-tracking refs, provide a prefix like
1398
+ --prefix=origin/ (remember the trailing slash), which will cause
1399
+ the SVN-tracking refs to be placed at refs/remotes/origin/*.
1400
+NOTE: In Git v2.0, the default prefix will change from empty to 'origin/'.
1401
+EOF
1402
+ }
1403
if (defined $url) {
1404
$url = canonicalize_url($url);
1405
init_subdir(@_);
t/t9117-git-svn-init-clone.sh
+67
@@ -52,4 +52,71 @@ test_expect_success 'clone to target directory with --stdlayout' '
52
rm -rf target
53
'
54
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
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 &&
66
+ test_must_fail grep -q prefix warning &&
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
+
86
+test_expect_success 'init with -s/-T/-b/-t without --prefix warns' '
87
+ test ! -d project &&
88
+ git svn init -s "$svnrepo"/project project 2>warning &&
89
+ grep -q prefix warning &&
90
+ test_svn_configured_prefix "" &&
91
+ rm -rf project &&
92
+ rm -f warning
93
+ '
94
+
95
+test_expect_success 'clone with -s/-T/-b/-t without --prefix warns' '
96
+ test ! -d project &&
97
+ git svn clone -s "$svnrepo"/project 2>warning &&
98
+ grep -q prefix warning &&
99
+ test_svn_configured_prefix "" &&
100
+ rm -rf project &&
101
+ rm -f warning
102
+ '
103
+
104
+test_expect_success 'init with -s/-T/-b/-t and --prefix does not warn' '
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
111
+ '
112
+
113
+test_expect_success 'clone with -s/-T/-b/-t and --prefix does not warn' '
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
120
+ '
121
+
122
test_done