summaryrefslogtreecommitdiff
path: root/git-svn.perl
diff options
context:
space:
mode:
authorMichael G. Schwern <schwern@pobox.com>2012-07-28 02:38:26 -0700
committerEric Wong <normalperson@yhbt.net>2012-08-02 21:43:02 +0000
commit91e6e0c56cc83e5f53d93e90726380a2d392f5f1 (patch)
treeadde002364bcca037ef6e072f77e1c60972c7969 /git-svn.perl
parentb1ea6c3829109aff412095b889432bf496f46a90 (diff)
downloadgit-91e6e0c56cc83e5f53d93e90726380a2d392f5f1.tar.gz
git-svn: move canonicalization to Git::SVN::Utils
So they can be used by others. I'd like to test them, but they're going to become SVN API wrappers shortly and those aren't predictable. No functional change. [ew: commit title] Signed-off-by: Eric Wong <normalperson@yhbt.net>
Diffstat (limited to 'git-svn.perl')
-rwxr-xr-xgit-svn.perl33
1 files changed, 7 insertions, 26 deletions
diff --git a/git-svn.perl b/git-svn.perl
index de1ddd1051..a857484c58 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -29,7 +29,13 @@ use Git::SVN::Prompt;
use Git::SVN::Log;
use Git::SVN::Migration;
-use Git::SVN::Utils qw(fatal can_compress);
+use Git::SVN::Utils qw(
+ fatal
+ can_compress
+ canonicalize_path
+ canonicalize_url
+);
+
use Git qw(
git_cmd_try
command
@@ -1256,31 +1262,6 @@ sub cmd_mkdirs {
$gs->mkemptydirs($_revision);
}
-sub canonicalize_path {
- my ($path) = @_;
- my $dot_slash_added = 0;
- if (substr($path, 0, 1) ne "/") {
- $path = "./" . $path;
- $dot_slash_added = 1;
- }
- # File::Spec->canonpath doesn't collapse x/../y into y (for a
- # good reason), so let's do this manually.
- $path =~ s#/+#/#g;
- $path =~ s#/\.(?:/|$)#/#g;
- $path =~ s#/[^/]+/\.\.##g;
- $path =~ s#/$##g;
- $path =~ s#^\./## if $dot_slash_added;
- $path =~ s#^/##;
- $path =~ s#^\.$##;
- return $path;
-}
-
-sub canonicalize_url {
- my ($url) = @_;
- $url =~ s#^([^:]+://[^/]*/)(.*)$#$1 . canonicalize_path($2)#e;
- return $url;
-}
-
# get_svnprops(PATH)
# ------------------
# Helper for cmd_propget and cmd_proplist below.