@matheusbsbs / matheus-bagliano / commits / a0fbc87cff
Fork 0

git-svn: Make branch use correct svn-remote

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>

Deskin Miller committed Dec 1, 2008 at 21:43 UTC a0fbc87cff6ae80c5b5be84201bc53252533b1fb
2 files changed +20 -1
git-svn.perl
+1 -1
@@ -558,7 +558,7 @@ sub cmd_branch {
558
559 my ($src, $rev, undef, $gs) = working_head_info($head);
560
561 - my $remote = Git::SVN::read_all_remotes()->{svn};
561 + my $remote = Git::SVN::read_all_remotes()->{$gs->{repo_id}};
562 my $glob = $remote->{ $_tag ? 'tags' : 'branches' };
563 my ($lft, $rgt) = @{ $glob->{path} }{qw/left right/};
564 my $dst = join '/', $remote->{url}, $lft, $branch_name, ($rgt || ());
t/t9128-git-svn-cmd-branch.sh
+19
@@ -56,4 +56,23 @@ test_expect_success 'git svn branch tests' '
56 test_must_fail git svn tag tag1
57 '
58
59 +test_expect_success 'branch uses correct svn-remote' '
60 + (svn co "$svnrepo" svn &&
61 + cd svn &&
62 + mkdir mirror &&
63 + svn add mirror &&
64 + svn copy trunk mirror/ &&
65 + svn copy tags mirror/ &&
66 + svn copy branches mirror/ &&
67 + svn ci -m "made mirror" ) &&
68 + rm -rf svn &&
69 + git svn init -s -R mirror --prefix=mirror/ "$svnrepo"/mirror &&
70 + git svn fetch -R mirror &&
71 + git checkout mirror/trunk &&
72 + base=$(git rev-parse HEAD:) &&
73 + git svn branch -m "branch in mirror" d &&
74 + test $base = $(git rev-parse remotes/mirror/d:) &&
75 + test_must_fail git rev-parse remotes/d
76 +'
77 +
78 test_done