summaryrefslogtreecommitdiffstats
path: root/quilt/scripts
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
commit12c0bdf9e743195de8e16b4af4cca2b7cc8a78e0 (patch)
treecf2eab2d0c1cf8178d8087e747c6150382b2c16c /quilt/scripts
parent4313f8222262def7e5042c87ac0c2722da2501c0 (diff)
downloadquilt-12c0bdf9e743195de8e16b4af4cca2b7cc8a78e0.tar.gz
backup-files: Try mass copy first on copy
When copying many files to a snapshot directory, try a mass copy first, as it is much faster. It is however not portable and may thus fail. If it fails, fallback to per-file processing, which always works. This change results in a huge performance boost on systems where the cp command supports all the required options (which includes all systems using GNU coreutils.) Signed-off-by: Jean Delvare <jdelvare@suse.de> Reviewed-by: Raphael Hertzog <hertzog@debian.org>
Diffstat (limited to 'quilt/scripts')
-rw-r--r--quilt/scripts/backup-files.in22
1 files changed, 18 insertions, 4 deletions
diff --git a/quilt/scripts/backup-files.in b/quilt/scripts/backup-files.in
index 32d3d50..487a155 100644
--- a/quilt/scripts/backup-files.in
+++ b/quilt/scripts/backup-files.in
@@ -261,10 +261,24 @@ copy_many()
done
exec 3>&-
- while read -d $'\0' -r
- do
- copy "$REPLY"
- done < "$NONEMPTY_FILES"
+ if [ -s "$NONEMPTY_FILES" ]; then
+ # Try a mass copy first, as it is much faster.
+ # It is however not portable and may thus fail. If it fails,
+ # fallback to per-file processing, which always works.
+
+ if xargs -0 cp -p --parents --target-directory="$OPT_PREFIX" \
+ < "$NONEMPTY_FILES" 2> /dev/null; then
+ while read -d $'\0' -r
+ do
+ $ECHO "Copying $REPLY"
+ done < "$NONEMPTY_FILES"
+ else
+ while read -d $'\0' -r
+ do
+ copy "$REPLY"
+ done < "$NONEMPTY_FILES"
+ fi
+ fi
}
# Test if some backed up files have a link count greater than 1