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
commitf039e051ce20db947f6c2d29cba91befcc998f95 (patch)
tree3125d1f80e00de87f350e4d8cee9dd61452bb8df
parent89ca89806f9f3735cb579ae8a45ed3c633a0c605 (diff)
downloadquilt-f039e051ce20db947f6c2d29cba91befcc998f95.tar.gz
backup-files: Optimize backup
Optimize backup: * Due to the way quilt uses backup-files, the backup file will never exist, so there is no point checking for this. * Don't attempt to create directories which already exist. * Use > instead of touch to create new files, it's faster. * Stop supporting option -t on backup, it's undocumented and quilt doesn't use it. * Drop unneeded quotes around constant. Signed-off-by: Jean Delvare <jdelvare@suse.de> Reviewed-by: Raphael Hertzog <hertzog@debian.org>
-rw-r--r--quilt/scripts/backup-files.in15
1 files changed, 5 insertions, 10 deletions
diff --git a/quilt/scripts/backup-files.in b/quilt/scripts/backup-files.in
index bff2b72..b9578c6 100644
--- a/quilt/scripts/backup-files.in
+++ b/quilt/scripts/backup-files.in
@@ -60,19 +60,17 @@ ensure_nolinks() {
backup() {
local file="$1"
local backup="${OPT_PREFIX}${file}"
+ local dir
- if [ -e "$backup" ]; then
- rm "$backup"
- else
- mkdir -p "$(dirname "$backup")"
- fi
+ dir=$(dirname "$backup")
+ [ -d "$dir" ] || mkdir -p "$dir"
if [ ! -e "$file" ]; then
$ECHO "New file $file"
- touch "$backup"
+ : > "$backup"
else
$ECHO "Copying $file"
- if [ -n "$OPT_NOLINKS" -a "$(stat @STAT_HARDLINK@ "$file")" = "1" ]; then
+ if [ -n "$OPT_NOLINKS" -a "$(stat @STAT_HARDLINK@ "$file")" = 1 ]; then
cp -p "$file" "$backup"
else
ln "$file" "$backup" 2> /dev/null || cp -p "$file" "$backup"
@@ -80,9 +78,6 @@ backup() {
ensure_nolinks "$file"
fi
fi
- if [ -n "$OPT_TOUCH" ]; then
- touch "$backup"
- fi
fi
}