[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Quilt-dev] filenames containing whitespace not handled correctly
From: |
Yasushi SHOJI |
Subject: |
Re: [Quilt-dev] filenames containing whitespace not handled correctly |
Date: |
Thu, 5 Nov 2009 20:20:44 +0900 |
User-agent: |
Wanderlust/2.14.0 |
Subject: [PATCH] add, files, remove: accept file name with spaces
http://savannah.nongnu.org/bugs/?19477 and
http://lists.nongnu.org/archive/html/quilt-dev/2009-09/msg00010.html
reported that the current quilt does not work with file name with
spaces. we all know that it is tough to handle it with bash script and
fix all quilt commands.
this patch only fixes add, files, and remove command with normal code
path. no excessive test has been done but a few test code is also
added. hope this starts fixing quilt to handle all possible path
pattern.
---
Hi Jean,
At Thu, 29 Oct 2009 10:46:37 +0100,
Jean Delvare wrote:
>
> Changing IFS and not restoring it afterwards looks wrong. Look at
> annotate.in, there the value of IFS is carefully saved and restored.
true. and thank you for reviewing my patch. I've reworked on IFS
save/restore and here is the revised version. hope you like it.
--
yashi
quilt/add.in | 16 ++++++++--------
quilt/files.in | 9 +++++++--
quilt/remove.in | 8 ++++----
quilt/scripts/patchfns.in | 10 ++++------
test/add-filename-check.test | 3 +++
test/remove-filename-check.test | 24 ++++++++++++++++++++++++
6 files changed, 50 insertions(+), 20 deletions(-)
create mode 100644 test/remove-filename-check.test
diff --git a/quilt/add.in b/quilt/add.in
index 373192f..dfd48f8 100644
--- a/quilt/add.in
+++ b/quilt/add.in
@@ -91,21 +91,21 @@ fi
patch=$(find_applied_patch "$opt_patch") || exit 1
status=0
-for file in $*
+for file in "$@"
do
- if ! in_valid_dir $SUBDIR$file
+ if ! in_valid_dir "$SUBDIR$file"
then
status=1
continue
fi
- if file_in_patch $SUBDIR$file $patch
+ if file_in_patch "$SUBDIR$file" $patch
then
printf $"File %s is already in patch %s\n" \
"$SUBDIR$file" "$(print_patch $patch)" >&2
[ $status -ne 1 ] && status=2
continue
fi
- next_patch=$(next_patch_for_file $patch $SUBDIR$file)
+ next_patch=$(next_patch_for_file $patch "$SUBDIR$file")
if [ -n "$next_patch" ]
then
printf $"File %s modified by patch %s\n" \
@@ -114,24 +114,24 @@ do
continue
fi
- if [ -L $SUBDIR$file ]
+ if [ -L "$SUBDIR$file" ]
then
printf $"Cannot add symbolic link %s\n" "$SUBDIR$file" >&2
status=1
continue
fi
- if ! $QUILT_LIB/backup-files -b -s -L -B $QUILT_PC/$patch/ $SUBDIR$file
+ if ! $QUILT_LIB/backup-files -b -s -L -B $QUILT_PC/$patch/
"$SUBDIR$file"
then
printf $"Failed to back up file %s\n" "$SUBDIR$file" >&2
status=1
continue
fi
- if [ -e $SUBDIR$file ]
+ if [ -e "$SUBDIR$file" ]
then
# The original tree may be read-only.
- chmod u+w $SUBDIR$file
+ chmod u+w "$SUBDIR$file"
fi
printf $"File %s added to patch %s\n" \
diff --git a/quilt/files.in b/quilt/files.in
index ba8b054..ef667d0 100644
--- a/quilt/files.in
+++ b/quilt/files.in
@@ -116,6 +116,7 @@ list_files_in_patch()
{
local patch=$1
local status
+ local saved_IFS="$IFS"
if [ -n "$opt_all" ] && [ -n "$opt_verbose" ] && [ -z "$opt_labels" ]
then
@@ -126,7 +127,10 @@ list_files_in_patch()
use_status=yes
fi
# Note: If opt_labels is set, then use_status is not set.
- for file in $(files_in_patch $patch | sort)
+ IFS=
+ echo $(files_in_patch "$patch") |
+ sort |
+ while read file
do
if [ -n "$opt_labels" ]
then
@@ -157,11 +161,12 @@ list_files_in_patch()
echo "$status $file"
fi
done
+ IFS="$saved_IFS"
}
for patch in address@hidden
do
- list_files_in_patch $patch
+ list_files_in_patch "$patch"
done
### Local Variables:
diff --git a/quilt/remove.in b/quilt/remove.in
index a11db0a..96a4e86 100644
--- a/quilt/remove.in
+++ b/quilt/remove.in
@@ -66,9 +66,9 @@ fi
patch=$(find_applied_patch "$opt_patch") || exit 1
status=0
-for file in $*
+for file in "$@"
do
- if ! file_in_patch $SUBDIR$file $patch
+ if ! file_in_patch "$SUBDIR$file" $patch
then
printf $"File %s is not in patch %s\n" \
"$SUBDIR$file" "$(print_patch $patch)" >&2
@@ -76,7 +76,7 @@ do
continue
fi
- next_patch=$(next_patch_for_file $patch $SUBDIR$file)
+ next_patch=$(next_patch_for_file $patch "$SUBDIR$file")
if [ -n "$next_patch" ]
then
printf $"File %s modified by patch %s\n" \
@@ -86,7 +86,7 @@ do
fi
# Restore file from backup
- if ! $QUILT_LIB/backup-files -r -t -s -B $QUILT_PC/$patch/ $SUBDIR$file
+ if ! $QUILT_LIB/backup-files -r -t -s -B $QUILT_PC/$patch/
"$SUBDIR$file"
then
printf $"Failed to remove file %s from patch %s\n" \
"$SUBDIR$file" "$(print_patch $patch)" >&2
diff --git a/quilt/scripts/patchfns.in b/quilt/scripts/patchfns.in
index 9723685..5707724 100644
--- a/quilt/scripts/patchfns.in
+++ b/quilt/scripts/patchfns.in
@@ -643,16 +643,14 @@ file_in_patch()
files_in_patch()
{
- local patch="$1"
+ local patch="$*"
local path="$QUILT_PC/$patch"
if [ -d "$path" ]
then
- local files
- files=( $(find "$path" -type f \
- -a ! -path "$path/.timestamp") ) \
- || return 1
- printf "%s\n" "address@hidden/}"
+ find "$path" -type f \
+ -a ! -path "$path/.timestamp" |
+ sed -e "s:$path/::"
fi
}
diff --git a/test/add-filename-check.test b/test/add-filename-check.test
index 306af66..aca4b9c 100644
--- a/test/add-filename-check.test
+++ b/test/add-filename-check.test
@@ -14,5 +14,8 @@ $ quilt add patches/bar
$ quilt add .pc/baz
> File .pc/baz is located below .pc/
+$ quilt add "foo bar"
+> File foo bar added to patch patches/test.diff
+
$ cd ..
$ rm -rf d
diff --git a/test/remove-filename-check.test b/test/remove-filename-check.test
new file mode 100644
index 0000000..1931a29
--- /dev/null
+++ b/test/remove-filename-check.test
@@ -0,0 +1,24 @@
+$ rm -rf d
+$ mkdir -p d/patches
+$ cd d
+$ quilt new test.diff
+>Patch patches/test.diff is now on top
+
+$ echo foo > foo
+$ quilt add foo
+> File foo added to patch patches/test.diff
+
+$ quilt add "foo bar"
+> File foo bar added to patch patches/test.diff
+
+$ quilt add "a b c"
+> File a b c added to patch patches/test.diff
+
+$quilt remove "a b c"
+> File a b c removed from patch patches/test.diff
+
+$quilt remove "foo bar"
+> File foo bar removed from patch patches/test.diff
+
+$ cd ..
+$ rm -rf d
--
1.6.5.1.31.gad12b
- Re: [Quilt-dev] filenames containing whitespace not handled correctly,
Yasushi SHOJI <=