quilt-dev
[Top][All Lists]
Advanced

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

[Quilt-dev] [PATCH 35/39] backup-files: Inline restore_fast


From: Jean Delvare
Subject: [Quilt-dev] [PATCH 35/39] backup-files: Inline restore_fast
Date: Sat, 19 Mar 2011 10:53:05 +0100
User-agent: quilt/0.48-17.1

The two callers of restore_fast already know if they are operating on
an empty or non-empty backup-file. Move the code back to the calling
sites, to avoid this redundant test.

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

--- a/quilt/scripts/backup-files.in
+++ b/quilt/scripts/backup-files.in
@@ -91,26 +91,6 @@ backup() {
        fi
 }
 
-# Same as restore, but assume that required directories are already
-# created, target files are already removed, and don't bother removing
-# the backup files or touching target files after restoration.
-restore_fast()
-{
-       local file=$1
-       local backup=$OPT_PREFIX$file
-
-       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
-}
-
 restore()
 {
        local file=$1
@@ -167,7 +147,7 @@ restore_all()
 
                while read -d $'\0' -r
                do
-                       restore_fast "${REPLY#./}"
+                       $ECHO "Removing ${REPLY#./}"
                done < "$EMPTY_FILES"
        fi
 
@@ -194,7 +174,15 @@ restore_all()
 
                        while read -d $'\0' -r
                        do
-                               restore_fast "${REPLY#./}"
+                               local file=${REPLY#./}
+                               local backup=$OPT_PREFIX$file
+
+                               $ECHO "Restoring $file"
+                               if [ -n "$OPT_NOLINKS" ]; then
+                                       cp -p "$backup" "$file"
+                               else
+                                       ln "$backup" "$file" 2> /dev/null || cp 
-p "$backup" "$file"
+                               fi
                        done < "$NONEMPTY_FILES"
                fi
 




reply via email to

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