quilt-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Quilt-dev] [PATCH] diff/refresh: Quote file names which contain a space


From: Jean Delvare
Subject: [Quilt-dev] [PATCH] diff/refresh: Quote file names which contain a space
Date: Wed, 12 Apr 2023 16:23:28 +0200

GNU diff quotes file names which contain a space, and GNU patch
expects that as well (oddly enough, only when the patch header does
not include timestamps). Do the same so that the patches we generate
can always be applied.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
---
 quilt/scripts/patchfns.in    |    7 ++++++-
 test/space-in-filenames.test |   18 +++++++++---------
 2 files changed, 15 insertions(+), 10 deletions(-)

--- quilt.orig/quilt/scripts/patchfns.in
+++ quilt/quilt/scripts/patchfns.in
@@ -692,7 +692,7 @@ files_in_patch_ordered()
 diff_file()
 {
        local file=$1 old_file=$2 new_file=$3
-       local index old_hdr old_date new_hdr new_date line
+       local index old_hdr old_date new_hdr new_date line regexp
 
        : ${opt_strip_level:=1}
        if [ $opt_strip_level = ab ]
@@ -735,6 +735,11 @@ diff_file()
                || new_date=$'\t'"1970-01-01 00:00:00.000000000 +0000"
        fi
 
+       # If a header contains a space character, it must be quoted
+       regexp="[[:space:]]"
+       [[ "$old_hdr" =~ $regexp ]] && old_hdr=\"$old_hdr\"
+       [[ "$new_hdr" =~ $regexp ]] && new_hdr=\"$new_hdr\"
+
        diff $QUILT_DIFF_OPTS \
             --label "$old_hdr$old_date" --label "$new_hdr$new_date" \
             "$old_file" "$new_file" \
--- quilt.orig/test/space-in-filenames.test
+++ quilt/test/space-in-filenames.test
@@ -44,13 +44,13 @@ $ quilt diff -p ab
 > Index: b/a: b [c]
 > ===================================================================
 > --- /dev/null
-> +++ b/a: b [c]
+> +++ "b/a: b [c]"
 > @@ -0,0 +1 @@
 > +new line
 > Index: b/foo bar
 > ===================================================================
-> --- a/foo bar
-> +++ b/foo bar
+> --- "a/foo bar"
+> +++ "b/foo bar"
 > @@ -1 +1 @@
 > -foo
 > +bar
@@ -61,13 +61,13 @@ $ cat patches/test.diff
 > Index: b/a: b [c]
 > ===================================================================
 > --- /dev/null
-> +++ b/a: b [c]
+> +++ "b/a: b [c]"
 > @@ -0,0 +1 @@
 > +new line
 > Index: b/foo bar
 > ===================================================================
-> --- a/foo bar
-> +++ b/foo bar
+> --- "a/foo bar"
+> +++ "b/foo bar"
 > @@ -1 +1 @@
 > -foo
 > +bar
@@ -78,13 +78,13 @@ $ cat patches/test.diff
 > Index: b/a: b [c]
 > ===================================================================
 > --- /dev/null
-> +++ b/a: b [c]
+> +++ "b/a: b [c]"
 > @@ -0,0 +1 @@
 > +new line
 > Index: b/foo bar
 > ===================================================================
-> --- a/foo bar
-> +++ b/foo bar
+> --- "a/foo bar"
+> +++ "b/foo bar"
 > @@ -1 +1 @@
 > -foo
 > +bar


-- 
Jean Delvare
SUSE L3 Support



reply via email to

[Prev in Thread] Current Thread [Next in Thread]