Skip to content

Commit 3def8d0

Browse files
schwernEric Wong
authored andcommitted
git-svn: path canonicalization uses SVN API
All tests pass with SVN 1.6. SVN 1.7 remains broken, not worrying about it yet. SVN changed its path canonicalization API between 1.6 and 1.7. http://svnbook.red-bean.com/en/1.6/svn.developer.usingapi.html#svn.developer.usingapi.urlpath http://svnbook.red-bean.com/en/1.7/svn.developer.usingapi.html#svn.developer.usingapi.urlpath The SVN API does not accept foo/.. but it also doesn't canonicalize it. We have to do it ourselves. [ew: commit title, fall back if SVN <= 1.6 fails to canonicalize] Signed-off-by: Eric Wong <normalperson@yhbt.net>
1 parent 8169a39 commit 3def8d0

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

perl/Git/SVN/Utils.pm

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,30 @@ sub _collapse_dotdot {
8686

8787

8888
sub canonicalize_path {
89+
my $path = shift;
90+
my $rv;
91+
92+
# The 1.7 way to do it
93+
if ( defined &SVN::_Core::svn_dirent_canonicalize ) {
94+
$path = _collapse_dotdot($path);
95+
$rv = SVN::_Core::svn_dirent_canonicalize($path);
96+
}
97+
# The 1.6 way to do it
98+
# This can return undef on subversion-perl-1.4.2-2.el5 (CentOS 5.2)
99+
elsif ( defined &SVN::_Core::svn_path_canonicalize ) {
100+
$path = _collapse_dotdot($path);
101+
$rv = SVN::_Core::svn_path_canonicalize($path);
102+
}
103+
104+
return $rv if defined $rv;
105+
106+
# No SVN API canonicalization is available, or the SVN API
107+
# didn't return a successful result, do it ourselves
108+
return _canonicalize_path_ourselves($path);
109+
}
110+
111+
112+
sub _canonicalize_path_ourselves {
89113
my ($path) = @_;
90114
my $dot_slash_added = 0;
91115
if (substr($path, 0, 1) ne "/") {

0 commit comments

Comments
 (0)