diff options
author | Michael G. Schwern <schwern@pobox.com> | 2012-07-28 02:38:28 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2012-08-02 21:43:58 +0000 |
commit | 280ad88aa0e851b2f2945222edb8e7b681a7574b (patch) | |
tree | 4c56e2de4aef88b6887589e3a9add119777ab677 /t/Git-SVN | |
parent | 82009f304826fcaf3188fb422769a7974ae78afa (diff) | |
download | git-280ad88aa0e851b2f2945222edb8e7b681a7574b.tar.gz git-280ad88aa0e851b2f2945222edb8e7b681a7574b.tar.xz |
git-svn: factor out _collapse_dotdot function
The SVN API functions will not accept ../foo but their canonicalization
functions will not collapse it. So we'll have to do it ourselves.
_collapse_dotdot() works better than the existing regex did.
This will be used shortly when canonicalize_path() starts using the
SVN API.
[ew: commit title]
Signed-off-by: Eric Wong <normalperson@yhbt.net>
Diffstat (limited to 't/Git-SVN')
-rw-r--r-- | t/Git-SVN/Utils/collapse_dotdot.t | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/t/Git-SVN/Utils/collapse_dotdot.t b/t/Git-SVN/Utils/collapse_dotdot.t new file mode 100644 index 000000000..1da1cce15 --- /dev/null +++ b/t/Git-SVN/Utils/collapse_dotdot.t @@ -0,0 +1,23 @@ +#!/usr/bin/env perl + +use strict; +use warnings; + +use Test::More 'no_plan'; + +use Git::SVN::Utils; +my $collapse_dotdot = \&Git::SVN::Utils::_collapse_dotdot; + +my %tests = ( + "foo/bar/baz" => "foo/bar/baz", + ".." => "..", + "foo/.." => "", + "/foo/bar/../../baz" => "/baz", + "deeply/.././deeply/nested" => "./deeply/nested", +); + +for my $arg (keys %tests) { + my $want = $tests{$arg}; + + is $collapse_dotdot->($arg), $want, "_collapse_dotdot('$arg') => $want"; +} |