git-svn: Make branch use correct svn-remote
authorDeskin Miller <deskinm@umich.edu>
Tue, 2 Dec 2008 02:43:00 +0000 (21:43 -0500)
committerJunio C Hamano <gitster@pobox.com>
Wed, 3 Dec 2008 09:54:24 +0000 (01:54 -0800)
The 'branch' subcommand incorrectly had the svn-remote to use hardcoded
as 'svn', the default remote name. This meant that branches derived
from other svn-remotes would try to use the branch and tag configuration
for the 'svn' remote, potentially copying would-be branches to the wrong
place in SVN, into the branch namespace for another project.

Fix this by using the remote name extracted from the svn info for the
specified git ref. Add a testcase for this behaviour.

[jc: squashed in a fix to test from Michael J Gruber for older svn (1.4)]

Signed-off-by: Deskin Miller <deskinm@umich.edu>
Acked-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-svn.perl
t/t9128-git-svn-cmd-branch.sh
index 914c707a90e5755879574b2717c064fd9364d054..e64e97b4de52156339c8d07a6e2ce262ba419522 100755 (executable)
@@ -558,7 +558,7 @@ sub cmd_branch {
 
        my ($src, $rev, undef, $gs) = working_head_info($head);
 
-       my $remote = Git::SVN::read_all_remotes()->{svn};
+       my $remote = Git::SVN::read_all_remotes()->{$gs->{repo_id}};
        my $glob = $remote->{ $_tag ? 'tags' : 'branches' };
        my ($lft, $rgt) = @{ $glob->{path} }{qw/left right/};
        my $dst = join '/', $remote->{url}, $lft, $branch_name, ($rgt || ());
index 47c4d4d938eea2ae193d8e4795a08d19a4900354..252daa7e1aec3c40a31db9a12a9432fbb85ef1b0 100755 (executable)
@@ -56,4 +56,23 @@ test_expect_success 'git svn branch tests' '
        test_must_fail git svn tag tag1
 '
 
+test_expect_success 'branch uses correct svn-remote' '
+       (svn co "$svnrepo" svn &&
+       cd svn &&
+       mkdir mirror &&
+       svn add mirror &&
+       svn copy trunk mirror/ &&
+       svn copy tags mirror/ &&
+       svn copy branches mirror/ &&
+       svn ci -m "made mirror" ) &&
+       rm -rf svn &&
+       git svn init -s -R mirror --prefix=mirror/ "$svnrepo"/mirror &&
+       git svn fetch -R mirror &&
+       git checkout mirror/trunk &&
+       base=$(git rev-parse HEAD:) &&
+       git svn branch -m "branch in mirror" d &&
+       test $base = $(git rev-parse remotes/mirror/d:) &&
+       test_must_fail git rev-parse remotes/d
+'
+
 test_done