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

git-svn: split the path from the url correctly with limited perms

This version of the splitter (that only affects SVN:: library users) works when one only has limited read-permissions to the repository they're fetching from. Updated from the original patch to workaround some SVN bug somewhere, which only seems to happen against file:// repositories... Here's the diff against the original patch I submitted: @@ -1159,8 +1159,8 @@ sub repo_path_split { } if ($_use_lib) { - $SVN = libsvn_connect($full_url); - my $url = $SVN->get_repos_root; + my $tmp = libsvn_connect($full_url); + my $url = $tmp->get_repos_root; $full_url =~ s#^\Q$url\E/*##; push @repo_path_split_cache, qr/^(\Q$url\E)/; return ($url, $full_url); Somehow connecting to a repository with the full url makes the returned SVN::Ra object act strangely and break things, so now we just drop the SVN::Ra object that we made our initial connection with. Signed-off-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Junio C Hamano <junkio@cox.net>

Eric Wong committed Aug 11, 2006 at 23:21 UTC a69a165fb43c88ab5c2adc2fe33b065ff537177c
1 file changed +11 -14
git-svn.perl
+11 -14
@@ -1158,27 +1158,24 @@ sub repo_path_split {
1158 }
1159 }
1160
1161 - my ($url, $path) = ($full_url =~ m!^([a-z\+]+://[^/]*)(.*)$!i);
1162 - $path =~ s#^/+##;
1163 - my @paths = split(m#/+#, $path);
1164 -
1161 if ($_use_lib) {
1166 - while (1) {
1167 - $SVN = libsvn_connect($url);
1168 - last if (defined $SVN &&
1169 - defined eval { $SVN->get_latest_revnum });
1170 - my $n = shift @paths || last;
1171 - $url .= "/$n";
1172 - }
1162 + my $tmp = libsvn_connect($full_url);
1163 + my $url = $tmp->get_repos_root;
1164 + $full_url =~ s#^\Q$url\E/*##;
1165 + push @repo_path_split_cache, qr/^(\Q$url\E)/;
1166 + return ($url, $full_url);
1167 } else {
1168 + my ($url, $path) = ($full_url =~ m!^([a-z\+]+://[^/]*)(.*)$!i);
1169 + $path =~ s#^/+##;
1170 + my @paths = split(m#/+#, $path);
1171 while (quiet_run(qw/svn ls --non-interactive/, $url)) {
1172 my $n = shift @paths || last;
1173 $url .= "/$n";
1174 }
1175 + push @repo_path_split_cache, qr/^(\Q$url\E)/;
1176 + $path = join('/',@paths);
1177 + return ($url, $path);
1178 }
1179 - push @repo_path_split_cache, qr/^(\Q$url\E)/;
1180 - $path = join('/',@paths);
1181 - return ($url, $path);
1179 }
1180
1181 sub setup_git_svn {