]> arthur.barton.de Git - bup.git/commitdiff
save: make --strip-path=/ a no-op
authorRob Browning <rlb@defaultvalue.org>
Sat, 7 Feb 2015 16:49:01 +0000 (10:49 -0600)
committerRob Browning <rlb@defaultvalue.org>
Mon, 16 Feb 2015 18:52:22 +0000 (12:52 -0600)
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 <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/helpers.py
lib/bup/t/thelpers.py

index 715ce3389dcc9550e9447fb86025c68c2d677707..c15b357733b378105a160ec8e829f92bdfe0bdaa 100644 (file)
@@ -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)
     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 = []
         if normalized_path.startswith(normalized_bp):
             prefix = normalized_path[:len(normalized_bp)]
             result = []
index 68004b72f03e69633fa765d776144a90c3e90b42..79eb4af444dd82380aa931bcb042984462035aaf 100644 (file)
@@ -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('/', []), [('', '/')])
     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')])
     WVPASSEQ(stripped_path_components('/', ['/foo']), [('', '/')])
     WVPASSEQ(stripped_path_components('/foo', ['/bar']),
              [('', '/'), ('foo', '/foo')])