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
commit73949d4f08b168116f30c9be0f1e282957e1a816 (patch)
treef673c141bc319b48693a2b5cc58bf69d4e07a324
parent17d39a0414a74ad87b6d86bd11dcdf5e2c468471 (diff)
downloadquilt-73949d4f08b168116f30c9be0f1e282957e1a816.tar.gz
backup-files: Optimize noop
Optimize the noop operation. The only use case in quilt is to ensure that files have a link count of 1, so we can check that OPT_NOLINKS is set once and for all, instead of checking again with every file. Signed-off-by: Jean Delvare <jdelvare@suse.de> Reviewed-by: Raphael Hertzog <hertzog@debian.org>
-rw-r--r--quilt/scripts/backup-files.in13
1 files changed, 10 insertions, 3 deletions
diff --git a/quilt/scripts/backup-files.in b/quilt/scripts/backup-files.in
index 5f01846..4e59de5 100644
--- a/quilt/scripts/backup-files.in
+++ b/quilt/scripts/backup-files.in
@@ -151,18 +151,17 @@ remove()
rmdir -p "${backup%/*}" 2> /dev/null || true
}
-noop()
+noop_nolinks()
{
local file=$1
- if [ -e "$file" ] && [ -n "$OPT_NOLINKS" ]; then
+ if [ -e "$file" ]; then
ensure_nolinks "$file"
fi
}
ECHO=echo
-OPT_WHAT=noop
while [ $# -gt 0 ]; do
case $1 in
-b) OPT_WHAT=backup
@@ -205,6 +204,14 @@ if [ "${OPT_PREFIX:(-1)}" != / ]; then
exit 1
fi
+if [ -z "$OPT_WHAT" ]; then
+ if [ -n "$OPT_NOLINKS" ]; then
+ OPT_WHAT=noop_nolinks
+ else
+ exit 0
+ fi
+fi
+
if [ -n "$OPT_FILE" ]; then
cat "$OPT_FILE" \
| while read nextfile; do