I broke "import -P" with my previous commit. Using this option now
fails with the following error message:
/usr/share/quilt/import: line 168: [: missing `]'

This is caused by a missing space before the closing square bracket,
which prevents bash from parsing the line.

Also add a test case to cover this code path, so that no such bug can
creep in in the future.

Signed-off-by: Jean Delvare <[email protected]>
Fixes: c539338458e4 ("Delay sourcing patchfns until options have been 
processed")
---
 quilt/import.in  |    2 +-
 test/import.test |   16 ++++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

--- quilt.orig/test/import.test 2021-08-30 09:53:04.265641553 +0200
+++ quilt/test/import.test      2021-08-30 09:53:24.372904686 +0200
@@ -255,3 +255,19 @@
        > Importing patch ../empty.patch (stored as %{_P}empty.patch)
        $ quilt import %{PWD}/empty2.patch
        > Importing patch %{PWD}/empty2.patch (stored as %{_P}empty2.patch)
+
+# Test importing under a different name
+       $ cd ..
+       $ quilt delete -rn
+       > Removed patch %{P}empty2.patch
+       $ quilt delete -rn
+       > Removed patch %{P}empty.patch
+       $ quilt import t/patch1.diff -P patch1-renamed.diff
+       > Importing patch t/patch1.diff (stored as %{P}patch1-renamed.diff)
+       $ quilt push
+       > Applying patch %{P}patch1-renamed.diff
+       > patching file f
+       >
+       > Now at patch patches/patch1-renamed.diff
+       $ cat f
+       > f
--- quilt.orig/quilt/import.in  2021-08-30 09:53:04.265641553 +0200
+++ quilt/quilt/import.in       2021-08-30 09:53:24.372904686 +0200
@@ -165,7 +165,7 @@ then
 fi
 . $QUILT_DIR/scripts/patchfns
 
-[ -n "$opt_patch"] && opt_patch=${opt_patch#$QUILT_PATCHES/}
+[ -n "$opt_patch" ] && opt_patch=${opt_patch#$QUILT_PATCHES/}
 [ -n "$opt_strip" ] && patch_args="-p$opt_strip"
 if [ -n "$opt_reverse" ]
 then


-- 
Jean Delvare
SUSE L3 Support

_______________________________________________
Quilt-dev mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/quilt-dev

Reply via email to