diff options
author | Jean Delvare <jdelvare@suse.de> | 2012-02-01 18:08:49 +0100 |
---|---|---|
committer | Jean Delvare <jdelvare@suse.de> | 2012-02-01 18:08:49 +0100 |
commit | caa8e96ac563214c7141183022cfa4a9147910b7 (patch) | |
tree | 0310ae6e583be3270e1baf05695f54cda96b30b8 | |
parent | 7d91ce9ddb0b48b97f133335f336780618b9bc05 (diff) | |
download | quilt-caa8e96ac563214c7141183022cfa4a9147910b7.tar.gz |
backup-files: Inline restore_fast
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 <jdelvare@suse.de>
Reviewed-by: Raphael Hertzog <hertzog@debian.org>
-rw-r--r-- | quilt/scripts/backup-files.in | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/quilt/scripts/backup-files.in b/quilt/scripts/backup-files.in index e989e5c..5cceb9c 100644 --- 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 |