Skip to content

Commit a0fbc87

Browse files
deskingitster
authored andcommitted
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>
1 parent 757c7f6 commit a0fbc87

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

git-svn.perl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ sub cmd_branch {
558558

559559
my ($src, $rev, undef, $gs) = working_head_info($head);
560560

561-
my $remote = Git::SVN::read_all_remotes()->{svn};
561+
my $remote = Git::SVN::read_all_remotes()->{$gs->{repo_id}};
562562
my $glob = $remote->{ $_tag ? 'tags' : 'branches' };
563563
my ($lft, $rgt) = @{ $glob->{path} }{qw/left right/};
564564
my $dst = join '/', $remote->{url}, $lft, $branch_name, ($rgt || ());

t/t9128-git-svn-cmd-branch.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,23 @@ test_expect_success 'git svn branch tests' '
5656
test_must_fail git svn tag tag1
5757
'
5858

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

0 commit comments

Comments
 (0)