[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Quilt-dev] [PATCH 25/39] backup-files: Separate function restore_all
From: |
Jean Delvare |
Subject: |
[Quilt-dev] [PATCH 25/39] backup-files: Separate function restore_all |
Date: |
Sat, 19 Mar 2011 10:52:55 +0100 |
User-agent: |
quilt/0.48-17.1 |
Move the code to restore all files from a backup directory to a
separate function. This only duplicates a small amount of code, and
makes the code clearer. This will also allow further optimizations of
the specific use case of "quilt pop".
Signed-off-by: Jean Delvare <address@hidden>
Reviewed-by: Raphael Hertzog <address@hidden>
---
quilt/scripts/backup-files.in | 50 ++++++++++++++++++++++++------------------
1 file changed, 29 insertions(+), 21 deletions(-)
--- a/quilt/scripts/backup-files.in
+++ b/quilt/scripts/backup-files.in
@@ -140,6 +140,33 @@ restore()
fi
}
+restore_all()
+{
+ (cd "$OPT_PREFIX" && find . -type d -print0) \
+ | xargs -0 mkdir -p
+ if [ ${PIPESTATUS[0]} != 0 ]; then
+ return 1
+ fi
+
+ (cd "$OPT_PREFIX" && find . -type f -print0) \
+ | xargs -0 -r rm -f
+
+ find "$OPT_PREFIX" -type f -print \
+ | while read
+ do
+ restore_fast "${REPLY#$OPT_PREFIX}"
+ done
+
+ if [ -n "$OPT_TOUCH" ]; then
+ (cd "$OPT_PREFIX" && find . -type f -size +0 -print0) \
+ | xargs -0 -r touch
+ fi
+
+ if [ -z "$OPT_KEEP_BACKUP" ]; then
+ rm -rf "$OPT_PREFIX"
+ fi
+}
+
remove()
{
local file=$1
@@ -227,16 +254,8 @@ fi
if [ "$1" = - ]; then
if [ "$OPT_WHAT" = restore ]; then
- OPT_WHAT=restore_fast
-
- (cd "$OPT_PREFIX" && find . -type d -print0) \
- | xargs -0 mkdir -p
- if [ ${PIPESTATUS[0]} != 0 ]; then
- exit 1
- fi
-
- (cd "$OPT_PREFIX" && find . -type f -print0) \
- | xargs -0 -r rm -f
+ restore_all
+ exit
fi
find "$OPT_PREFIX" -type f -print \
@@ -247,17 +266,6 @@ if [ "$1" = - ]; then
if [ ${PIPESTATUS[0]} != 0 ]; then
exit 1
fi
-
- if [ "$OPT_WHAT" = restore_fast ]; then
- if [ -n "$OPT_TOUCH" ]; then
- (cd "$OPT_PREFIX" && find . -type f -size +0 -print0) \
- | xargs -0 -r touch
- fi
-
- if [ -z "$OPT_KEEP_BACKUP" ]; then
- rm -rf "$OPT_PREFIX"
- fi
- fi
exit
fi
- [Quilt-dev] [PATCH 00/39] Reimplement backup-files in bash, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 03/39] BSD compatibility: cp, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 02/39] BSD compatibility: stat, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 21/39] backup-files: Drop curly braces, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 07/39] backup-files: Skip test for file presence, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 18/39] backup-files: Make input methods mutually exclusive, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 25/39] backup-files: Separate function restore_all,
Jean Delvare <=
- [Quilt-dev] [PATCH 26/39] backup-files: Quick exit when unlinking is not needed, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 13/39] backup-files: Split code to sparate functions, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 24/39] backup-files: Avoid negations, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 14/39] backup-files: Mass reindent, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 01/39] Make backup-files a shell script, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 22/39] backup-files: Check if backup exists, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 12/39] backup-files: Simplify find loop, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 15/39] backup-files: Optimize restore, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 23/39] backup-files: Optimize noop, Jean Delvare, 2011/03/19