Commits

Anonymous committed a69a165

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>

Comments (0)

Files changed (1)

 		}
 	}
 
-	my ($url, $path) = ($full_url =~ m!^([a-z\+]+://[^/]*)(.*)$!i);
-	$path =~ s#^/+##;
-	my @paths = split(m#/+#, $path);
-
 	if ($_use_lib) {
-		while (1) {
-			$SVN = libsvn_connect($url);
-			last if (defined $SVN &&
-				defined eval { $SVN->get_latest_revnum });
-			my $n = shift @paths || last;
-			$url .= "/$n";
-		}
+		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);
 	} else {
+		my ($url, $path) = ($full_url =~ m!^([a-z\+]+://[^/]*)(.*)$!i);
+		$path =~ s#^/+##;
+		my @paths = split(m#/+#, $path);
 		while (quiet_run(qw/svn ls --non-interactive/, $url)) {
 			my $n = shift @paths || last;
 			$url .= "/$n";
 		}
+		push @repo_path_split_cache, qr/^(\Q$url\E)/;
+		$path = join('/',@paths);
+		return ($url, $path);
 	}
-	push @repo_path_split_cache, qr/^(\Q$url\E)/;
-	$path = join('/',@paths);
-	return ($url, $path);
 }
 
 sub setup_git_svn {
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.