summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Delvare <jdelvare@suse.de>2012-02-01 18:08:49 +0100
committerJean Delvare <jdelvare@suse.de>2012-02-01 18:08:49 +0100
commit8a3f9645e0ea2709df4d4c68b352e46afe07919c (patch)
tree21e2e3f44a0567defb4558f6869242a420167193
parentf94d39d031ab6975bf506ffc03ab4bfe5be03584 (diff)
downloadquilt-8a3f9645e0ea2709df4d4c68b352e46afe07919c.tar.gz
backup-files: Separate function restore_all
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 <jdelvare@suse.de> Reviewed-by: Raphael Hertzog <hertzog@debian.org>
-rw-r--r--quilt/scripts/backup-files.in50
1 files changed, 29 insertions, 21 deletions
diff --git a/quilt/scripts/backup-files.in b/quilt/scripts/backup-files.in
index db4c008..5ee3c4f 100644
--- 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
@@ -225,16 +252,8 @@ if [ "$1" = - ]; then
[ -d "$OPT_PREFIX" ] || exit 0
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 \
@@ -245,17 +264,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