SHA256
1
0
forked from pool/quilt
quilt/hackweek-11-07-normalize-path.patch
Takashi Iwai a5de1023e1 Accepting request 264454 from home:jdelvare:branches:devel:tools:scm
- Fix the series file consistency checker
- Many fixes and improvements to the setup command
- New option --fast for quilt setup (hackweek project)

OBS-URL: https://build.opensuse.org/request/show/264454
OBS-URL: https://build.opensuse.org/package/show/devel:tools:scm/quilt?expand=0&rev=92
2014-12-10 16:05:56 +00:00

48 lines
1.2 KiB
Diff

From: Jean Delvare <jdelvare@suse.de>
Subject: setup: Introduce function normalize_path
Upstream: Committed (1e8e4ff9b8027235d0577369719c0c58ba460cf8)
Move the path normalization code to a separate function, to avoid
redundancy and make the code more readable.
---
quilt/setup.in | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
--- a/quilt/setup.in
+++ b/quilt/setup.in
@@ -71,6 +71,15 @@ check_for_existing_files()
return $status
}
+# Resolve ".." in path and clean up double slashes
+normalize_path()
+{
+ echo "$1" | sed -r -e 's://:/:g' \
+ -e ':again' \
+ -e 's:/[^/]+/\.\.(/|$):\1:g' \
+ -e 'tagain'
+}
+
create_symlink()
{
local target=$1 link=$2 up
@@ -80,16 +89,8 @@ create_symlink()
return
fi
- set -- "$(echo "$PWD/$target" | \
- sed -r -e 's://:/:g' \
- -e ':again' \
- -e 's:/[^/]+/\.\.(/|$):\1:g' \
- -e 'tagain')" \
- "$(echo "$PWD/$link" | \
- sed -r -e 's://:/:g' \
- -e ':again' \
- -e 's:/[^/]+/\.\.(/|$):\1:g' \
- -e 'tagain')"
+ set -- "$(normalize_path "$PWD/$target")" \
+ "$(normalize_path "$PWD/$link")"
while [ "${1%%/*}" = "${2%%/*}" ]
do
set -- "${1#*/}" "${2#*/}"