From 1e6960cc99f293c740d6ab4c9f0bd4008f5626d2 Mon Sep 17 00:00:00 2001 From: Rob Browning Date: Sat, 7 Feb 2015 10:49:01 -0600 Subject: [PATCH] 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 --- lib/bup/helpers.py | 2 ++ lib/bup/t/thelpers.py | 2 ++ 2 files changed, 4 insertions(+) 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')]) -- 2.39.2