git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Deskin Miller <deskinm@umich.edu>
To: git@vger.kernel.org
Cc: gitster@pobox.com, normalperson@yhbt.net,
	Deskin Miller <deskinm@umich.edu>
Subject: [PATCH] git-svn: Make branch use correct svn-remote
Date: Mon,  1 Dec 2008 21:43:00 -0500	[thread overview]
Message-ID: <1228185780-22938-1-git-send-email-deskinm@umich.edu> (raw)

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.

Signed-off-by: Deskin Miller <deskinm@umich.edu>
---
Applies on v1.6.1-rc1.  Apologies for not catching this when first
writing testcases for the branch subcommand.

Deskin Miller

 git-svn.perl                  |    2 +-
 t/t9128-git-svn-cmd-branch.sh |   17 +++++++++++++++++
 2 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/git-svn.perl b/git-svn.perl
index 914c707..e64e97b 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -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 || ());
diff --git a/t/t9128-git-svn-cmd-branch.sh b/t/t9128-git-svn-cmd-branch.sh
index 47c4d4d..e2b6696 100755
--- a/t/t9128-git-svn-cmd-branch.sh
+++ b/t/t9128-git-svn-cmd-branch.sh
@@ -56,4 +56,21 @@ 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 tags 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
-- 
1.6.1.rc1

             reply	other threads:[~2008-12-02  2:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-02  2:43 Deskin Miller [this message]
2008-12-02 21:51 ` [PATCH] git-svn: Make branch use correct svn-remote Eric Wong
2008-12-03  3:55   ` Junio C Hamano
2008-12-03  9:30     ` [PATCH] Make t9128-git-svn-cmd-branch pass with svn 1.4 Michael J Gruber
2008-12-03  9:33     ` [PATCH] git-svn: Make branch use correct svn-remote Michael J Gruber
2008-12-03 20:06       ` Junio C Hamano
2008-12-03 20:42         ` Deskin Miller
2008-12-04 19:26       ` Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1228185780-22938-1-git-send-email-deskinm@umich.edu \
    --to=deskinm@umich.edu \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=normalperson@yhbt.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).