Skip to content

Commit f849bb6

Browse files
jherlandEric Wong
authored andcommitted
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 <[email protected]> Signed-off-by: Johan Herland <[email protected]> Signed-off-by: Eric Wong <[email protected]>
1 parent 7091a2d commit f849bb6

File tree

3 files changed

+88
-2
lines changed

3 files changed

+88
-2
lines changed

Documentation/git-svn.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@ COMMANDS
8686
(refs/remotes/$remote/*). Setting a prefix is also useful
8787
if you wish to track multiple projects that share a common
8888
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+
8997
--ignore-paths=<regex>;;
9098
When passed to 'init' or 'clone' this regular expression will
9199
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/*.
9931001
The former is more compatible with the layout of Git's "regular"
9941002
remote-tracking refs (refs/remotes/$remote/*), and may potentially
9951003
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/".
9971006

9981007
When using multiple --branches or --tags, 'git svn' does not automatically
9991008
handle name collisions (for example, if two branches from different paths have

git-svn.perl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1389,7 +1389,17 @@ sub cmd_multi_init {
13891389
usage(1);
13901390
}
13911391

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+
}
13931403
if (defined $url) {
13941404
$url = canonicalize_url($url);
13951405
init_subdir(@_);

t/t9117-git-svn-init-clone.sh

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,71 @@ test_expect_success 'clone to target directory with --stdlayout' '
5252
rm -rf target
5353
'
5454

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+
55122
test_done

0 commit comments

Comments
 (0)