From fe29b7b749b2f339182fdec685c7adbb798234c1 Mon Sep 17 00:00:00 2001 From: Rob Browning Date: Mon, 30 Jun 2014 13:15:58 -0500 Subject: [PATCH 1/1] Ignore empty lines in --exclude-rx-from files Thanks to Daniel Hahler Daniel Hahler for suggesting the change. Signed-off-by: Rob Browning Tested-by: Rob Browning --- Documentation/bup-drecurse.md | 2 +- Documentation/bup-index.md | 2 +- Documentation/bup-restore.md | 2 +- lib/bup/helpers.py | 2 ++ t/test-save-restore-excludes.sh | 5 ++++- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Documentation/bup-drecurse.md b/Documentation/bup-drecurse.md index 86477de..66683a2 100644 --- a/Documentation/bup-drecurse.md +++ b/Documentation/bup-drecurse.md @@ -53,7 +53,7 @@ come after its children, making this easy. \--exclude-rx-from=*filename* : read --exclude-rx patterns from *filename*, one pattern per-line - (may be repeated). + (may be repeated). Ignore completely empty lines. \--profile : print profiling information upon completion. Useful diff --git a/Documentation/bup-index.md b/Documentation/bup-index.md index 9fa9b35..e4dd2ac 100644 --- a/Documentation/bup-index.md +++ b/Documentation/bup-index.md @@ -171,7 +171,7 @@ does, due to the accommodations described above. \--exclude-rx-from=*filename* : read --exclude-rx patterns from *filename*, one pattern per-line - (may be repeated). + (may be repeated). Ignore completely empty lines. \--no-check-device : don't mark a an entry invalid if the device number (stat(2) diff --git a/Documentation/bup-restore.md b/Documentation/bup-restore.md index ed7cd74..9f33133 100644 --- a/Documentation/bup-restore.md +++ b/Documentation/bup-restore.md @@ -119,7 +119,7 @@ See the EXAMPLES section for a demonstration. \--exclude-rx-from=*filename* : read --exclude-rx patterns from *filename*, one pattern per-line - (may be repeated). + (may be repeated). Ignore completely empty lines. \--map-user *old*=*new* : for every path, restore the *old* (saved) user name as *new*. diff --git a/lib/bup/helpers.py b/lib/bup/helpers.py index 1b390c5..93bcc07 100644 --- a/lib/bup/helpers.py +++ b/lib/bup/helpers.py @@ -835,6 +835,8 @@ def parse_rx_excludes(options, fatal): raise fatal("couldn't read %s" % parameter) for pattern in f.readlines(): spattern = pattern.rstrip('\n') + if not spattern: + continue try: excluded_patterns.append(re.compile(spattern)) except re.error, ex: diff --git a/t/test-save-restore-excludes.sh b/t/test-save-restore-excludes.sh index 97f4c72..0b073c5 100755 --- a/t/test-save-restore-excludes.sh +++ b/t/test-save-restore-excludes.sh @@ -174,7 +174,10 @@ WVPASS mkdir src/sub1 WVPASS mkdir src/sub2 WVPASS touch src/sub1/a WVPASS touch src/sub2/b -WVPASS echo "^$(pwd)/src/sub1/" > exclude-rx-file +# exclude-rx-file includes blank lines to check that we ignore them. +WVPASS echo "^$(pwd)/src/sub1/ + +" > exclude-rx-file WVPASS bup index -u src --exclude-rx-from exclude-rx-file WVPASS bup save --strip -n bupdir src WVPASS bup restore -C buprestore.tmp /bupdir/latest/ -- 2.39.2