From: Rob Browning Date: Sat, 7 Feb 2015 16:49:01 +0000 (-0600) Subject: save: make --strip-path=/ a no-op X-Git-Tag: 0.27-rc1~2 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=bup.git;a=commitdiff_plain;h=1e6960cc99f293c740d6ab4c9f0bd4008f5626d2 save: make --strip-path=/ a no-op When --strip-path=/ is specified, don't treat it as --strip-path=/{usr,lib,...}, instead do nothing. Thanks to Mark J Hewitt for reporting the problem. Signed-off-by: Rob Browning Tested-by: Rob Browning --- diff --git a/lib/bup/helpers.py b/lib/bup/helpers.py index 715ce33..c15b357 100644 --- a/lib/bup/helpers.py +++ b/lib/bup/helpers.py @@ -930,6 +930,8 @@ def stripped_path_components(path, strip_prefixes): sorted_strip_prefixes = sorted(strip_prefixes, key=len, reverse=True) for bp in sorted_strip_prefixes: normalized_bp = os.path.abspath(bp) + if normalized_bp == '/': + continue if normalized_path.startswith(normalized_bp): prefix = normalized_path[:len(normalized_bp)] result = [] diff --git a/lib/bup/t/thelpers.py b/lib/bup/t/thelpers.py index 68004b7..79eb4af 100644 --- a/lib/bup/t/thelpers.py +++ b/lib/bup/t/thelpers.py @@ -70,6 +70,8 @@ def test_stripped_path_components(): WVPASSEQ(stripped_path_components('/', []), [('', '/')]) WVPASSEQ(stripped_path_components('/', ['']), [('', '/')]) WVPASSEQ(stripped_path_components('/', ['/']), [('', '/')]) + WVPASSEQ(stripped_path_components('/foo', ['/']), + [('', '/'), ('foo', '/foo')]) WVPASSEQ(stripped_path_components('/', ['/foo']), [('', '/')]) WVPASSEQ(stripped_path_components('/foo', ['/bar']), [('', '/'), ('foo', '/foo')])