Skip to content

Commit aeaa7e2

Browse files
committed
Merge git://bogomips.org/git-svn
* git://bogomips.org/git-svn: Git 2.0: git svn: Set default --prefix='origin/' if --prefix is not given
2 parents 8fe3ee6 + fe191fc commit aeaa7e2

20 files changed

+131
-153
lines changed

Documentation/git-svn.txt

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,11 @@ 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+
By default, the prefix is set to 'origin/'.
8990
+
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.
91+
NOTE: Before Git v2.0, the default prefix was "" (no prefix). This
92+
meant that SVN-tracking refs were put at "refs/remotes/*", which is
93+
incompatible with how Git's own remote-tracking refs are organized.
9694

9795
--ignore-paths=<regex>;;
9896
When passed to 'init' or 'clone' this regular expression will
@@ -994,16 +992,6 @@ without giving any repository layout options. If the full history with
994992
branches and tags is required, the options '--trunk' / '--branches' /
995993
'--tags' must be used.
996994

997-
When using the options for describing the repository layout (--trunk,
998-
--tags, --branches, --stdlayout), please also specify the --prefix
999-
option (e.g. '--prefix=origin/') to cause your SVN-tracking refs to be
1000-
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
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-
1007995
When using multiple --branches or --tags, 'git svn' does not automatically
1008996
handle name collisions (for example, if two branches from different paths have
1009997
the same name, or if a branch and a tag have the same name). In these cases,

git-svn.perl

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

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-
}
1392+
$_prefix = 'origin/' unless defined $_prefix;
14031393
if (defined $url) {
14041394
$url = canonicalize_url($url);
14051395
init_subdir(@_);

t/t9107-git-svn-migrate.sh

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -45,42 +45,42 @@ test_expect_success 'initialize old-style (v0) git svn layout' '
4545
test_expect_success 'initialize a multi-repository repo' '
4646
git svn init "$svnrepo" -T trunk -t tags -b branches &&
4747
git config --get-all svn-remote.svn.fetch > fetch.out &&
48-
grep "^trunk:refs/remotes/trunk$" fetch.out &&
48+
grep "^trunk:refs/remotes/origin/trunk$" fetch.out &&
4949
test -n "`git config --get svn-remote.svn.branches \
50-
"^branches/\*:refs/remotes/\*$"`" &&
50+
"^branches/\*:refs/remotes/origin/\*$"`" &&
5151
test -n "`git config --get svn-remote.svn.tags \
52-
"^tags/\*:refs/remotes/tags/\*$"`" &&
52+
"^tags/\*:refs/remotes/origin/tags/\*$"`" &&
5353
git config --unset svn-remote.svn.branches \
54-
"^branches/\*:refs/remotes/\*$" &&
54+
"^branches/\*:refs/remotes/origin/\*$" &&
5555
git config --unset svn-remote.svn.tags \
56-
"^tags/\*:refs/remotes/tags/\*$" &&
57-
git config --add svn-remote.svn.fetch "branches/a:refs/remotes/a" &&
58-
git config --add svn-remote.svn.fetch "branches/b:refs/remotes/b" &&
56+
"^tags/\*:refs/remotes/origin/tags/\*$" &&
57+
git config --add svn-remote.svn.fetch "branches/a:refs/remotes/origin/a" &&
58+
git config --add svn-remote.svn.fetch "branches/b:refs/remotes/origin/b" &&
5959
for i in tags/0.1 tags/0.2 tags/0.3; do
6060
git config --add svn-remote.svn.fetch \
61-
$i:refs/remotes/$i || exit 1; done &&
61+
$i:refs/remotes/origin/$i || exit 1; done &&
6262
git config --get-all svn-remote.svn.fetch > fetch.out &&
63-
grep "^trunk:refs/remotes/trunk$" fetch.out &&
64-
grep "^branches/a:refs/remotes/a$" fetch.out &&
65-
grep "^branches/b:refs/remotes/b$" fetch.out &&
66-
grep "^tags/0\.1:refs/remotes/tags/0\.1$" fetch.out &&
67-
grep "^tags/0\.2:refs/remotes/tags/0\.2$" fetch.out &&
68-
grep "^tags/0\.3:refs/remotes/tags/0\.3$" fetch.out &&
63+
grep "^trunk:refs/remotes/origin/trunk$" fetch.out &&
64+
grep "^branches/a:refs/remotes/origin/a$" fetch.out &&
65+
grep "^branches/b:refs/remotes/origin/b$" fetch.out &&
66+
grep "^tags/0\.1:refs/remotes/origin/tags/0\.1$" fetch.out &&
67+
grep "^tags/0\.2:refs/remotes/origin/tags/0\.2$" fetch.out &&
68+
grep "^tags/0\.3:refs/remotes/origin/tags/0\.3$" fetch.out &&
6969
grep "^:refs/${remotes_git_svn}" fetch.out
7070
'
7171

7272
# refs should all be different, but the trees should all be the same:
7373
test_expect_success 'multi-fetch works on partial urls + paths' "
7474
git svn multi-fetch &&
7575
for i in trunk a b tags/0.1 tags/0.2 tags/0.3; do
76-
git rev-parse --verify refs/remotes/\$i^0 >> refs.out || exit 1;
76+
git rev-parse --verify refs/remotes/origin/\$i^0 >> refs.out || exit 1;
7777
done &&
7878
test -z \"\`sort < refs.out | uniq -d\`\" &&
7979
for i in trunk a b tags/0.1 tags/0.2 tags/0.3; do
8080
for j in trunk a b tags/0.1 tags/0.2 tags/0.3; do
8181
if test \$j != \$i; then continue; fi
82-
test -z \"\`git diff refs/remotes/\$i \
83-
refs/remotes/\$j\`\" ||exit 1; done; done
82+
test -z \"\`git diff refs/remotes/origin/\$i \
83+
refs/remotes/origin/\$j\`\" ||exit 1; done; done
8484
"
8585

8686
test_expect_success 'migrate --minimize on old inited layout' '
@@ -98,27 +98,27 @@ test_expect_success 'migrate --minimize on old inited layout' '
9898
git svn migrate --minimize &&
9999
test -z "`git config -l | grep "^svn-remote\.git-svn\."`" &&
100100
git config --get-all svn-remote.svn.fetch > fetch.out &&
101-
grep "^trunk:refs/remotes/trunk$" fetch.out &&
102-
grep "^branches/a:refs/remotes/a$" fetch.out &&
103-
grep "^branches/b:refs/remotes/b$" fetch.out &&
104-
grep "^tags/0\.1:refs/remotes/tags/0\.1$" fetch.out &&
105-
grep "^tags/0\.2:refs/remotes/tags/0\.2$" fetch.out &&
106-
grep "^tags/0\.3:refs/remotes/tags/0\.3$" fetch.out &&
101+
grep "^trunk:refs/remotes/origin/trunk$" fetch.out &&
102+
grep "^branches/a:refs/remotes/origin/a$" fetch.out &&
103+
grep "^branches/b:refs/remotes/origin/b$" fetch.out &&
104+
grep "^tags/0\.1:refs/remotes/origin/tags/0\.1$" fetch.out &&
105+
grep "^tags/0\.2:refs/remotes/origin/tags/0\.2$" fetch.out &&
106+
grep "^tags/0\.3:refs/remotes/origin/tags/0\.3$" fetch.out &&
107107
grep "^:refs/${remotes_git_svn}" fetch.out
108108
'
109109

110110
test_expect_success ".rev_db auto-converted to .rev_map.UUID" '
111111
git svn fetch -i trunk &&
112-
test -z "$(ls "$GIT_DIR"/svn/refs/remotes/trunk/.rev_db.* 2>/dev/null)" &&
113-
expect="$(ls "$GIT_DIR"/svn/refs/remotes/trunk/.rev_map.*)" &&
112+
test -z "$(ls "$GIT_DIR"/svn/refs/remotes/origin/trunk/.rev_db.* 2>/dev/null)" &&
113+
expect="$(ls "$GIT_DIR"/svn/refs/remotes/origin/trunk/.rev_map.*)" &&
114114
test -n "$expect" &&
115115
rev_db="$(echo $expect | sed -e "s,_map,_db,")" &&
116116
convert_to_rev_db "$expect" "$rev_db" &&
117117
rm -f "$expect" &&
118118
test -f "$rev_db" &&
119119
git svn fetch -i trunk &&
120-
test -z "$(ls "$GIT_DIR"/svn/refs/remotes/trunk/.rev_db.* 2>/dev/null)" &&
121-
test ! -e "$GIT_DIR"/svn/refs/remotes/trunk/.rev_db &&
120+
test -z "$(ls "$GIT_DIR"/svn/refs/remotes/origin/trunk/.rev_db.* 2>/dev/null)" &&
121+
test ! -e "$GIT_DIR"/svn/refs/remotes/origin/trunk/.rev_db &&
122122
test -f "$expect"
123123
'
124124

t/t9114-git-svn-dcommit-merge.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ test_expect_success 'setup svn repository' '
4848
test_expect_success 'setup git mirror and merge' '
4949
git svn init "$svnrepo" -t tags -T trunk -b branches &&
5050
git svn fetch &&
51-
git checkout -b svn remotes/trunk &&
51+
git checkout -b svn remotes/origin/trunk &&
5252
git checkout -b merge &&
5353
echo new file > new_file &&
5454
git add new_file &&
@@ -81,7 +81,7 @@ test_debug 'gitk --all & sleep 1'
8181

8282
test_expect_success 'verify post-merge ancestry' "
8383
test x\`git rev-parse --verify refs/heads/svn\` = \
84-
x\`git rev-parse --verify refs/remotes/trunk \` &&
84+
x\`git rev-parse --verify refs/remotes/origin/trunk \` &&
8585
test x\`git rev-parse --verify refs/heads/svn^2\` = \
8686
x\`git rev-parse --verify refs/heads/merge\` &&
8787
git cat-file commit refs/heads/svn^ | grep '^friend$'

t/t9116-git-svn-log.sh

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,20 @@ test_expect_success 'setup repository and import' '
2020
) &&
2121
git svn init "$svnrepo" -T trunk -b branches -t tags &&
2222
git svn fetch &&
23-
git reset --hard trunk &&
23+
git reset --hard origin/trunk &&
2424
echo bye >> README &&
2525
git commit -a -m bye &&
2626
git svn dcommit &&
27-
git reset --hard a &&
27+
git reset --hard origin/a &&
2828
echo why >> FEEDME &&
2929
git update-index --add FEEDME &&
3030
git commit -m feedme &&
3131
git svn dcommit &&
32-
git reset --hard trunk &&
32+
git reset --hard origin/trunk &&
3333
echo aye >> README &&
3434
git commit -a -m aye &&
3535
git svn dcommit &&
36-
git reset --hard b &&
36+
git reset --hard origin/b &&
3737
echo spy >> README &&
3838
git commit -a -m spy &&
3939
echo try >> README &&
@@ -42,34 +42,34 @@ test_expect_success 'setup repository and import' '
4242
'
4343

4444
test_expect_success 'run log' "
45-
git reset --hard a &&
46-
git svn log -r2 trunk | grep ^r2 &&
47-
git svn log -r4 trunk | grep ^r4 &&
45+
git reset --hard origin/a &&
46+
git svn log -r2 origin/trunk | grep ^r2 &&
47+
git svn log -r4 origin/trunk | grep ^r4 &&
4848
git svn log -r3 | grep ^r3
4949
"
5050

5151
test_expect_success 'run log against a from trunk' "
52-
git reset --hard trunk &&
53-
git svn log -r3 a | grep ^r3
52+
git reset --hard origin/trunk &&
53+
git svn log -r3 origin/a | grep ^r3
5454
"
5555

5656
printf 'r1 \nr2 \nr4 \n' > expected-range-r1-r2-r4
5757

5858
test_expect_success 'test ascending revision range' "
59-
git reset --hard trunk &&
59+
git reset --hard origin/trunk &&
6060
git svn log -r 1:4 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r1-r2-r4 -
6161
"
6262

6363
test_expect_success 'test ascending revision range with --show-commit' "
64-
git reset --hard trunk &&
64+
git reset --hard origin/trunk &&
6565
git svn log --show-commit -r 1:4 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r1-r2-r4 -
6666
"
6767

6868
test_expect_success 'test ascending revision range with --show-commit (sha1)' "
6969
git svn find-rev r1 >expected-range-r1-r2-r4-sha1 &&
7070
git svn find-rev r2 >>expected-range-r1-r2-r4-sha1 &&
7171
git svn find-rev r4 >>expected-range-r1-r2-r4-sha1 &&
72-
git reset --hard trunk &&
72+
git reset --hard origin/trunk &&
7373
git svn log --show-commit -r 1:4 | grep '^r[0-9]' | cut -d'|' -f2 >out &&
7474
git rev-parse \$(cat out) >actual &&
7575
test_cmp expected-range-r1-r2-r4-sha1 actual
@@ -78,67 +78,67 @@ test_expect_success 'test ascending revision range with --show-commit (sha1)' "
7878
printf 'r4 \nr2 \nr1 \n' > expected-range-r4-r2-r1
7979

8080
test_expect_success 'test descending revision range' "
81-
git reset --hard trunk &&
81+
git reset --hard origin/trunk &&
8282
git svn log -r 4:1 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4-r2-r1 -
8383
"
8484

8585
printf 'r1 \nr2 \n' > expected-range-r1-r2
8686

8787
test_expect_success 'test ascending revision range with unreachable revision' "
88-
git reset --hard trunk &&
88+
git reset --hard origin/trunk &&
8989
git svn log -r 1:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r1-r2 -
9090
"
9191

9292
printf 'r2 \nr1 \n' > expected-range-r2-r1
9393

9494
test_expect_success 'test descending revision range with unreachable revision' "
95-
git reset --hard trunk &&
95+
git reset --hard origin/trunk &&
9696
git svn log -r 3:1 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r2-r1 -
9797
"
9898

9999
printf 'r2 \n' > expected-range-r2
100100

101101
test_expect_success 'test ascending revision range with unreachable upper boundary revision and 1 commit' "
102-
git reset --hard trunk &&
102+
git reset --hard origin/trunk &&
103103
git svn log -r 2:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r2 -
104104
"
105105

106106
test_expect_success 'test descending revision range with unreachable upper boundary revision and 1 commit' "
107-
git reset --hard trunk &&
107+
git reset --hard origin/trunk &&
108108
git svn log -r 3:2 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r2 -
109109
"
110110

111111
printf 'r4 \n' > expected-range-r4
112112

113113
test_expect_success 'test ascending revision range with unreachable lower boundary revision and 1 commit' "
114-
git reset --hard trunk &&
114+
git reset --hard origin/trunk &&
115115
git svn log -r 3:4 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
116116
"
117117

118118
test_expect_success 'test descending revision range with unreachable lower boundary revision and 1 commit' "
119-
git reset --hard trunk &&
119+
git reset --hard origin/trunk &&
120120
git svn log -r 4:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
121121
"
122122

123123
printf -- '------------------------------------------------------------------------\n' > expected-separator
124124

125125
test_expect_success 'test ascending revision range with unreachable boundary revisions and no commits' "
126-
git reset --hard trunk &&
126+
git reset --hard origin/trunk &&
127127
git svn log -r 5:6 | test_cmp expected-separator -
128128
"
129129

130130
test_expect_success 'test descending revision range with unreachable boundary revisions and no commits' "
131-
git reset --hard trunk &&
131+
git reset --hard origin/trunk &&
132132
git svn log -r 6:5 | test_cmp expected-separator -
133133
"
134134

135135
test_expect_success 'test ascending revision range with unreachable boundary revisions and 1 commit' "
136-
git reset --hard trunk &&
136+
git reset --hard origin/trunk &&
137137
git svn log -r 3:5 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
138138
"
139139

140140
test_expect_success 'test descending revision range with unreachable boundary revisions and 1 commit' "
141-
git reset --hard trunk &&
141+
git reset --hard origin/trunk &&
142142
git svn log -r 5:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
143143
"
144144

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,25 +83,25 @@ EOF
8383
rm -f expect actual
8484
}
8585

86-
test_expect_success 'init with -s/-T/-b/-t without --prefix warns' '
86+
test_expect_success 'init with -s/-T/-b/-t assumes --prefix=origin/' '
8787
test ! -d project &&
8888
git svn init -s "$svnrepo"/project project 2>warning &&
89-
grep -q prefix warning &&
90-
test_svn_configured_prefix "" &&
89+
test_must_fail grep -q prefix warning &&
90+
test_svn_configured_prefix "origin/" &&
9191
rm -rf project &&
9292
rm -f warning
9393
'
9494

95-
test_expect_success 'clone with -s/-T/-b/-t without --prefix warns' '
95+
test_expect_success 'clone with -s/-T/-b/-t assumes --prefix=origin/' '
9696
test ! -d project &&
9797
git svn clone -s "$svnrepo"/project 2>warning &&
98-
grep -q prefix warning &&
99-
test_svn_configured_prefix "" &&
98+
test_must_fail grep -q prefix warning &&
99+
test_svn_configured_prefix "origin/" &&
100100
rm -rf project &&
101101
rm -f warning
102102
'
103103

104-
test_expect_success 'init with -s/-T/-b/-t and --prefix does not warn' '
104+
test_expect_success 'init with -s/-T/-b/-t and --prefix="" still works' '
105105
test ! -d project &&
106106
git svn init -s "$svnrepo"/project project --prefix="" 2>warning &&
107107
test_must_fail grep -q prefix warning &&
@@ -110,7 +110,7 @@ test_expect_success 'init with -s/-T/-b/-t and --prefix does not warn' '
110110
rm -f warning
111111
'
112112

113-
test_expect_success 'clone with -s/-T/-b/-t and --prefix does not warn' '
113+
test_expect_success 'clone with -s/-T/-b/-t and --prefix="" still works' '
114114
test ! -d project &&
115115
git svn clone -s "$svnrepo"/project --prefix="" 2>warning &&
116116
test_must_fail grep -q prefix warning &&

0 commit comments

Comments
 (0)