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>

Michael G. Schwern committed Jul 28, 2012 at 02:38 UTC 3def8d088499b94919de36305ce710487a5e2bb0
1 file changed +24
perl/Git/SVN/Utils.pm
+24
@@ -86,6 +86,30 @@ sub _collapse_dotdot {
86
87
88 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 {
113 my ($path) = @_;
114 my $dot_slash_added = 0;
115 if (substr($path, 0, 1) ne "/") {