import: allow -P optarg to be a directory

Quilt import command is modified such that

  quilt import -P DIR PATCH

adds PATCH as QUILT_PATCHES/DIR/PATCH to the series file, without the
need to type the patch name two times, thus saving some keystrokes.

Signed-off-by: H. Eitzenberger <[EMAIL PROTECTED]>

---
commit 69cf76eb309385694a0e77d5021a1d587ca3b4e2
tree 4e76d3bc43550b68a553b63c933525b9d52b7e5b
parent ba6081530f8598c78adbd577bd98a6ff8bfc1fe3
author Holger Eitzenberger <[EMAIL PROTECTED]> Fri, 22 Dec 2006 12:01:22 +0100
committer Holger Eitzenberger <[EMAIL PROTECTED]> Fri, 22 Dec 2006 12:01:22 
+0100

 quilt/import.in |   22 ++++++++++++++--------
 1 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/quilt/import.in b/quilt/import.in
index 9ee3b35..0d2d6bd 100644
--- a/quilt/import.in
+++ b/quilt/import.in
@@ -19,7 +19,7 @@ fi
 
 usage()
 {
-       printf $"Usage: quilt import [-p num] [-P patch] [-f] [-d {o|a|n}] 
patchfile ...\n"
+       printf $"Usage: quilt import [-p num] [-P patch|dir] [-f] [-d {o|a|n}] 
patchfile ...\n"
        if [ x$1 = x-h ]
        then
                printf $"
@@ -29,9 +29,10 @@ current top patch, and must be pushed after import to apply 
them.
 -p num
        Number of directory levels to strip when applying (default=1)
 
--P patch
-       Patch filename to use inside quilt. This option can only be
-       used when importing a single patch.
+-P patch|dir
+    Patch filename to use inside quilt. This option can only be used when
+    importing a single patch.  If you specify a directory the patch will
+    be added below this directory.  The original name will then be used.
 
 -f     Overwite/update existing patches.
 
@@ -128,10 +129,15 @@ do
         esac
 done
 
-if [ $# -gt 1 -a -n "$opt_patch" ]
-then
-       printf $"Option \`-P' can only be used when importing a single patch\n" 
>&2
-       exit 1
+if [ -n "$opt_patch" ]; then
+       if [ $# -gt 1 ]; then
+               printf $"Option \`-P' can only be used when importing a single 
patch\n" >&2
+               exit 1
+       fi
+
+       if [ -d "${QUILT_PATCHES:+$QUILT_PATCHES/}$opt_patch" ]; then
+               opt_patch="$opt_patch/${1##*/}"
+       fi
 fi
 
 [ -n "$opt_strip" ] && patch_args="-p$opt_strip"


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

Reply via email to