Skip to content

Commit

Permalink
Merge git://bogomips.org/git-svn
Browse files Browse the repository at this point in the history
* git://bogomips.org/git-svn:
  Git 2.0: git svn: Set default --prefix='origin/' if --prefix is not given
  • Loading branch information
Junio C Hamano committed Apr 21, 2014
2 parents 8fe3ee6 + fe191fc commit aeaa7e2
Show file tree
Hide file tree
Showing 20 changed files with 131 additions and 153 deletions.
20 changes: 4 additions & 16 deletions Documentation/git-svn.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,11 @@ COMMANDS
(refs/remotes/$remote/*). Setting a prefix is also useful
if you wish to track multiple projects that share a common
repository.
By default, the prefix is set to 'origin/'.
+
NOTE: In Git v2.0, the default prefix will CHANGE from "" (no prefix)
to "origin/". This is done to put SVN-tracking refs at
"refs/remotes/origin/*" instead of "refs/remotes/*", and make them
more compatible with how Git's own remote-tracking refs are organized
(i.e. refs/remotes/$remote/*). You can enjoy the same benefits today,
by using the --prefix option.
NOTE: Before Git v2.0, the default prefix was "" (no prefix). This
meant that SVN-tracking refs were put at "refs/remotes/*", which is
incompatible with how Git's own remote-tracking refs are organized.

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

When using the options for describing the repository layout (--trunk,
--tags, --branches, --stdlayout), please also specify the --prefix
option (e.g. '--prefix=origin/') to cause your SVN-tracking refs to be
placed at refs/remotes/origin/* rather than the default refs/remotes/*.
The former is more compatible with the layout of Git's "regular"
remote-tracking refs (refs/remotes/$remote/*), and may potentially
prevent similarly named SVN branches and Git remotes from clobbering
each other. In Git v2.0 the default prefix used (i.e. when no --prefix
is given) will change from "" (no prefix) to "origin/".

When using multiple --branches or --tags, 'git svn' does not automatically
handle name collisions (for example, if two branches from different paths have
the same name, or if a branch and a tag have the same name). In these cases,
Expand Down
12 changes: 1 addition & 11 deletions git-svn.perl
Original file line number Diff line number Diff line change
Expand Up @@ -1389,17 +1389,7 @@ sub cmd_multi_init {
usage(1);
}

unless (defined $_prefix) {
$_prefix = '';
warn <<EOF
WARNING: --prefix is not given, defaulting to empty prefix.
This is probably not what you want! In order to stay compatible
with regular remote-tracking refs, provide a prefix like
--prefix=origin/ (remember the trailing slash), which will cause
the SVN-tracking refs to be placed at refs/remotes/origin/*.
NOTE: In Git v2.0, the default prefix will change from empty to 'origin/'.
EOF
}
$_prefix = 'origin/' unless defined $_prefix;
if (defined $url) {
$url = canonicalize_url($url);
init_subdir(@_);
Expand Down
54 changes: 27 additions & 27 deletions t/t9107-git-svn-migrate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,42 +45,42 @@ test_expect_success 'initialize old-style (v0) git svn layout' '
test_expect_success 'initialize a multi-repository repo' '
git svn init "$svnrepo" -T trunk -t tags -b branches &&
git config --get-all svn-remote.svn.fetch > fetch.out &&
grep "^trunk:refs/remotes/trunk$" fetch.out &&
grep "^trunk:refs/remotes/origin/trunk$" fetch.out &&
test -n "`git config --get svn-remote.svn.branches \
"^branches/\*:refs/remotes/\*$"`" &&
"^branches/\*:refs/remotes/origin/\*$"`" &&
test -n "`git config --get svn-remote.svn.tags \
"^tags/\*:refs/remotes/tags/\*$"`" &&
"^tags/\*:refs/remotes/origin/tags/\*$"`" &&
git config --unset svn-remote.svn.branches \
"^branches/\*:refs/remotes/\*$" &&
"^branches/\*:refs/remotes/origin/\*$" &&
git config --unset svn-remote.svn.tags \
"^tags/\*:refs/remotes/tags/\*$" &&
git config --add svn-remote.svn.fetch "branches/a:refs/remotes/a" &&
git config --add svn-remote.svn.fetch "branches/b:refs/remotes/b" &&
"^tags/\*:refs/remotes/origin/tags/\*$" &&
git config --add svn-remote.svn.fetch "branches/a:refs/remotes/origin/a" &&
git config --add svn-remote.svn.fetch "branches/b:refs/remotes/origin/b" &&
for i in tags/0.1 tags/0.2 tags/0.3; do
git config --add svn-remote.svn.fetch \
$i:refs/remotes/$i || exit 1; done &&
$i:refs/remotes/origin/$i || exit 1; done &&
git config --get-all svn-remote.svn.fetch > fetch.out &&
grep "^trunk:refs/remotes/trunk$" fetch.out &&
grep "^branches/a:refs/remotes/a$" fetch.out &&
grep "^branches/b:refs/remotes/b$" fetch.out &&
grep "^tags/0\.1:refs/remotes/tags/0\.1$" fetch.out &&
grep "^tags/0\.2:refs/remotes/tags/0\.2$" fetch.out &&
grep "^tags/0\.3:refs/remotes/tags/0\.3$" fetch.out &&
grep "^trunk:refs/remotes/origin/trunk$" fetch.out &&
grep "^branches/a:refs/remotes/origin/a$" fetch.out &&
grep "^branches/b:refs/remotes/origin/b$" fetch.out &&
grep "^tags/0\.1:refs/remotes/origin/tags/0\.1$" fetch.out &&
grep "^tags/0\.2:refs/remotes/origin/tags/0\.2$" fetch.out &&
grep "^tags/0\.3:refs/remotes/origin/tags/0\.3$" fetch.out &&
grep "^:refs/${remotes_git_svn}" fetch.out
'

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

test_expect_success 'migrate --minimize on old inited layout' '
Expand All @@ -98,27 +98,27 @@ test_expect_success 'migrate --minimize on old inited layout' '
git svn migrate --minimize &&
test -z "`git config -l | grep "^svn-remote\.git-svn\."`" &&
git config --get-all svn-remote.svn.fetch > fetch.out &&
grep "^trunk:refs/remotes/trunk$" fetch.out &&
grep "^branches/a:refs/remotes/a$" fetch.out &&
grep "^branches/b:refs/remotes/b$" fetch.out &&
grep "^tags/0\.1:refs/remotes/tags/0\.1$" fetch.out &&
grep "^tags/0\.2:refs/remotes/tags/0\.2$" fetch.out &&
grep "^tags/0\.3:refs/remotes/tags/0\.3$" fetch.out &&
grep "^trunk:refs/remotes/origin/trunk$" fetch.out &&
grep "^branches/a:refs/remotes/origin/a$" fetch.out &&
grep "^branches/b:refs/remotes/origin/b$" fetch.out &&
grep "^tags/0\.1:refs/remotes/origin/tags/0\.1$" fetch.out &&
grep "^tags/0\.2:refs/remotes/origin/tags/0\.2$" fetch.out &&
grep "^tags/0\.3:refs/remotes/origin/tags/0\.3$" fetch.out &&
grep "^:refs/${remotes_git_svn}" fetch.out
'

test_expect_success ".rev_db auto-converted to .rev_map.UUID" '
git svn fetch -i trunk &&
test -z "$(ls "$GIT_DIR"/svn/refs/remotes/trunk/.rev_db.* 2>/dev/null)" &&
expect="$(ls "$GIT_DIR"/svn/refs/remotes/trunk/.rev_map.*)" &&
test -z "$(ls "$GIT_DIR"/svn/refs/remotes/origin/trunk/.rev_db.* 2>/dev/null)" &&
expect="$(ls "$GIT_DIR"/svn/refs/remotes/origin/trunk/.rev_map.*)" &&
test -n "$expect" &&
rev_db="$(echo $expect | sed -e "s,_map,_db,")" &&
convert_to_rev_db "$expect" "$rev_db" &&
rm -f "$expect" &&
test -f "$rev_db" &&
git svn fetch -i trunk &&
test -z "$(ls "$GIT_DIR"/svn/refs/remotes/trunk/.rev_db.* 2>/dev/null)" &&
test ! -e "$GIT_DIR"/svn/refs/remotes/trunk/.rev_db &&
test -z "$(ls "$GIT_DIR"/svn/refs/remotes/origin/trunk/.rev_db.* 2>/dev/null)" &&
test ! -e "$GIT_DIR"/svn/refs/remotes/origin/trunk/.rev_db &&
test -f "$expect"
'

Expand Down
4 changes: 2 additions & 2 deletions t/t9114-git-svn-dcommit-merge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ test_expect_success 'setup svn repository' '
test_expect_success 'setup git mirror and merge' '
git svn init "$svnrepo" -t tags -T trunk -b branches &&
git svn fetch &&
git checkout -b svn remotes/trunk &&
git checkout -b svn remotes/origin/trunk &&
git checkout -b merge &&
echo new file > new_file &&
git add new_file &&
Expand Down Expand Up @@ -81,7 +81,7 @@ test_debug 'gitk --all & sleep 1'

test_expect_success 'verify post-merge ancestry' "
test x\`git rev-parse --verify refs/heads/svn\` = \
x\`git rev-parse --verify refs/remotes/trunk \` &&
x\`git rev-parse --verify refs/remotes/origin/trunk \` &&
test x\`git rev-parse --verify refs/heads/svn^2\` = \
x\`git rev-parse --verify refs/heads/merge\` &&
git cat-file commit refs/heads/svn^ | grep '^friend$'
Expand Down
46 changes: 23 additions & 23 deletions t/t9116-git-svn-log.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ test_expect_success 'setup repository and import' '
) &&
git svn init "$svnrepo" -T trunk -b branches -t tags &&
git svn fetch &&
git reset --hard trunk &&
git reset --hard origin/trunk &&
echo bye >> README &&
git commit -a -m bye &&
git svn dcommit &&
git reset --hard a &&
git reset --hard origin/a &&
echo why >> FEEDME &&
git update-index --add FEEDME &&
git commit -m feedme &&
git svn dcommit &&
git reset --hard trunk &&
git reset --hard origin/trunk &&
echo aye >> README &&
git commit -a -m aye &&
git svn dcommit &&
git reset --hard b &&
git reset --hard origin/b &&
echo spy >> README &&
git commit -a -m spy &&
echo try >> README &&
Expand All @@ -42,34 +42,34 @@ test_expect_success 'setup repository and import' '
'

test_expect_success 'run log' "
git reset --hard a &&
git svn log -r2 trunk | grep ^r2 &&
git svn log -r4 trunk | grep ^r4 &&
git reset --hard origin/a &&
git svn log -r2 origin/trunk | grep ^r2 &&
git svn log -r4 origin/trunk | grep ^r4 &&
git svn log -r3 | grep ^r3
"

test_expect_success 'run log against a from trunk' "
git reset --hard trunk &&
git svn log -r3 a | grep ^r3
git reset --hard origin/trunk &&
git svn log -r3 origin/a | grep ^r3
"

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Expand Down
16 changes: 8 additions & 8 deletions t/t9117-git-svn-init-clone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,25 +83,25 @@ EOF
rm -f expect actual
}

test_expect_success 'init with -s/-T/-b/-t without --prefix warns' '
test_expect_success 'init with -s/-T/-b/-t assumes --prefix=origin/' '
test ! -d project &&
git svn init -s "$svnrepo"/project project 2>warning &&
grep -q prefix warning &&
test_svn_configured_prefix "" &&
test_must_fail grep -q prefix warning &&
test_svn_configured_prefix "origin/" &&
rm -rf project &&
rm -f warning
'

test_expect_success 'clone with -s/-T/-b/-t without --prefix warns' '
test_expect_success 'clone with -s/-T/-b/-t assumes --prefix=origin/' '
test ! -d project &&
git svn clone -s "$svnrepo"/project 2>warning &&
grep -q prefix warning &&
test_svn_configured_prefix "" &&
test_must_fail grep -q prefix warning &&
test_svn_configured_prefix "origin/" &&
rm -rf project &&
rm -f warning
'

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

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

0 comments on commit aeaa7e2

Please sign in to comment.