git svn: the branch command no longer needs the full path
This was introduced in 0b2af457a49e3b00d47d556d5301934d27909db8 ("Fix branch detection when repository root is inaccessible") but reintroduced in the previous commit. Signed-off-by: Eric Wong <normalperson@yhbt.net>
Eric Wong committed
Jul 25, 2009 at 01:36 UTC
eaa14ff8c7dbe51dfdfe7e2d9ede839fc62dcf52
2 files changed
+20
-7
git-svn.perl
+16
-3
@@ -666,9 +666,22 @@ sub cmd_branch {
666
}
667
}
668
unless (defined $glob) {
669
- die "Unknown ",
670
- $_tag ? "tag" : "branch",
671
- " destination $_branch_dest\n";
669
+ my $dest_re = qr/\b\Q$_branch_dest\E\b/;
670
+ foreach my $g (@{$allglobs}) {
671
+ $g->{path}->{left} =~ /$dest_re/ or next;
672
+ if (defined $glob) {
673
+ die "Ambiguous destination: ",
674
+ $_branch_dest, "\nmatches both '",
675
+ $glob->{path}->{left}, "' and '",
676
+ $g->{path}->{left}, "'\n";
677
+ }
678
+ $glob = $g;
679
+ }
680
+ unless (defined $glob) {
681
+ die "Unknown ",
682
+ $_tag ? "tag" : "branch",
683
+ " destination $_branch_dest\n";
684
+ }
685
}
686
}
687
my ($lft, $rgt) = @{ $glob->{path} }{qw/left right/};
t/t9141-git-svn-multiple-branches.sh
+4
-4
@@ -99,22 +99,22 @@ test_expect_success 'Multiple branch or tag paths require -d' '
99
100
test_expect_success 'create new branches and tags' '
101
( cd git_project &&
102
- git svn branch -m "New branch 1" -d project/b_one New1 ) &&
102
+ git svn branch -m "New branch 1" -d b_one New1 ) &&
103
( cd svn_project &&
104
svn_cmd up && test -e b_one/New1/a.file ) &&
105
106
( cd git_project &&
107
- git svn branch -m "New branch 2" -d project/b_two New2 ) &&
107
+ git svn branch -m "New branch 2" -d b_two New2 ) &&
108
( cd svn_project &&
109
svn_cmd up && test -e b_two/New2/a.file ) &&
110
111
( cd git_project &&
112
- git svn branch -t -m "New tag 1" -d project/tags_A Tag1 ) &&
112
+ git svn branch -t -m "New tag 1" -d tags_A Tag1 ) &&
113
( cd svn_project &&
114
svn_cmd up && test -e tags_A/Tag1/a.file ) &&
115
116
( cd git_project &&
117
- git svn tag -m "New tag 2" -d project/tags_B Tag2 ) &&
117
+ git svn tag -m "New tag 2" -d tags_B Tag2 ) &&
118
( cd svn_project &&
119
svn_cmd up && test -e tags_B/Tag2/a.file )
120
'