quilt-dev
[Top][All Lists]
Advanced

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

[Quilt-dev] [PATCH] patches: Find file name with a space in unapplied pa


From: Jean Delvare
Subject: [Quilt-dev] [PATCH] patches: Find file name with a space in unapplied patches
Date: Wed, 12 Apr 2023 17:20:48 +0200

Fix the file name heuristic to also find quoted file names in
unapplied patches.

This fixes bug #41708:
https://savannah.nongnu.org/bugs/index.php?41708

Signed-off-by: Jean Delvare <jdelvare@suse.de>
---
I'm not necessarily proud of this piece of awk code, I'm not familiar
with this language. I changed it just enough to let the test suite run
without breaking anything else. If anyone can think of a better way,
speak up.

 quilt/scripts/patchfns.in    |   10 +++++++--
 test/space-in-filenames.test |   44 ++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 51 insertions(+), 3 deletions(-)

--- quilt.orig/quilt/scripts/patchfns.in
+++ quilt/quilt/scripts/patchfns.in
@@ -655,8 +655,14 @@ filenames_in_patch()
                awk '
                $1 == "+++" || $1 == "---" && $3 != "----" || \
                $1 == "***" && $3 != "****" \
-                       { sub(/\t.*/, "")
-                         if (sub(/^... /, "") == 0 || $0 == "" || $0 == 
"/dev/null")
+                       { if (sub(/^... /, "") == 0)
+                               next
+                         # File name may be quoted
+                         if (sub(/^\"/, ""))
+                               sub(/\"(\t.*|$)/, "")
+                         else
+                               sub(/\t.*/, "")
+                         if ($0 == "" || $0 == "/dev/null")
                                next
                          for (n=0 ; n<'$strip'; n++)
                              sub(/^[^\/]+\//, "")
--- quilt.orig/test/space-in-filenames.test
+++ quilt/test/space-in-filenames.test
@@ -3,9 +3,9 @@ $ mkdir patches
 $ quilt new test.diff
 > Patch %{P}test.diff is now on top
 
-$ echo foo > foo
 $ quilt add foo
 > File foo added to patch %{P}test.diff
+$ echo foo > foo
 
 $ quilt files
 > foo
@@ -47,6 +47,12 @@ $ quilt diff -p ab
 > +++ "b/a: b [c]"
 > @@ -0,0 +1 @@
 > +new line
+> Index: b/foo
+> ===================================================================
+> --- /dev/null
+> +++ b/foo
+> @@ -0,0 +1 @@
+> +foo
 > Index: b/foo bar
 > ===================================================================
 > --- "a/foo bar"
@@ -64,6 +70,12 @@ $ cat patches/test.diff
 > +++ "b/a: b [c]"
 > @@ -0,0 +1 @@
 > +new line
+> Index: b/foo
+> ===================================================================
+> --- /dev/null
+> +++ b/foo
+> @@ -0,0 +1 @@
+> +foo
 > Index: b/foo bar
 > ===================================================================
 > --- "a/foo bar"
@@ -81,6 +93,12 @@ $ cat patches/test.diff
 > +++ "b/a: b [c]"
 > @@ -0,0 +1 @@
 > +new line
+> Index: b/foo
+> ===================================================================
+> --- /dev/null
+> +++ b/foo
+> @@ -0,0 +1 @@
+> +foo
 > Index: b/foo bar
 > ===================================================================
 > --- "a/foo bar"
@@ -96,6 +114,30 @@ $ quilt grep new
 $ quilt grep " "
 > a: b [c]:new line
 
+$ quilt diff -p ab -z
+
+$ quilt pop
+> Removing patch patches/test.diff
+> Removing a: b [c]
+> Removing foo
+> Restoring foo bar
+>
+> No patches applied
+
+$ quilt patches "foo bar"
+> %{P}test.diff
+
+$ quilt patches "a: b [c]"
+> %{P}test.diff
+
+$ quilt push
+> Applying patch patches/test.diff
+> patching file a: b [c]
+> patching file foo
+> patching file foo bar
+>
+> Now at patch patches/test.diff
+
 $ quilt remove "a: b [c]"
 > File a: b [c] removed from patch %{P}test.diff
 

-- 
Jean Delvare
SUSE L3 Support



reply via email to

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