quilt-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Quilt-dev] [PATCH 24/39] backup-files: Avoid negations


From: Jean Delvare
Subject: [Quilt-dev] [PATCH 24/39] backup-files: Avoid negations
Date: Sat, 19 Mar 2011 10:52:54 +0100
User-agent: quilt/0.48-17.1

In if/else constructs, always start with the positive case, to avoid
a negation.

Signed-off-by: Jean Delvare <address@hidden>
Reviewed-by: Raphael Hertzog <address@hidden>
---
 quilt/scripts/backup-files.in |   26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

--- a/quilt/scripts/backup-files.in
+++ b/quilt/scripts/backup-files.in
@@ -67,10 +67,7 @@ backup() {
        dir=$(dirname "$backup")
        [ -d "$dir" ] || mkdir -p "$dir"
 
-       if [ ! -e "$file" ]; then
-               $ECHO "New file $file"
-               : > "$backup"
-       else
+       if [ -e "$file" ]; then
                $ECHO "Copying $file"
                if [ -n "$OPT_NOLINKS" -a "$(stat @STAT_HARDLINK@ "$file")" = 1 
]; then
                        cp -p "$file" "$backup"
@@ -80,6 +77,9 @@ backup() {
                                ensure_nolinks "$file"
                        fi
                fi
+       else
+               $ECHO "New file $file"
+               : > "$backup"
        fi
 }
 
@@ -91,15 +91,15 @@ restore_fast()
        local file=$1
        local backup=$OPT_PREFIX$file
 
-       if [ ! -s "$backup" ]; then
-               $ECHO "Removing $file"
-       else
+       if [ -s "$backup" ]; then
                $ECHO "Restoring $file"
                if [ -n "$OPT_NOLINKS" ]; then
                        cp -p "$backup" "$file"
                else
                        ln "$backup" "$file" 2> /dev/null || cp -p "$backup" 
"$file"
                fi
+       else
+               $ECHO "Removing $file"
        fi
 }
 
@@ -111,12 +111,7 @@ restore()
        if [ ! -e "$backup" ]; then
                return 1
        fi
-       if [ ! -s "$backup" ]; then
-               $ECHO "Removing $file"
-               if [ -e "$file" ]; then
-                       rm "$file"
-               fi
-       else
+       if [ -s "$backup" ]; then
                $ECHO "Restoring $file"
                if [ -e "$file" ]; then
                        rm "$file"
@@ -132,6 +127,11 @@ restore()
                if [ -n "$OPT_TOUCH" ]; then
                        touch "$file"
                fi
+       else
+               $ECHO "Removing $file"
+               if [ -e "$file" ]; then
+                       rm "$file"
+               fi
        fi
 
        if [ -z "$OPT_KEEP_BACKUP" ]; then




reply via email to

[Prev in Thread] Current Thread [Next in Thread]