quilt-dev
[Top][All Lists]
Advanced

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

Re: [Quilt-dev] quilt new overrides SUBDIR


From: Joe Green
Subject: Re: [Quilt-dev] quilt new overrides SUBDIR
Date: Mon, 12 Jul 2004 09:13:29 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113

Andreas Gruenbacher wrote:
Indeed. The idea behind this was as follows: If a patches sub-directory exists further up the tree but not in the root of the working tree, the new command will break out of the working tree and create patches further up the tree. I repeatedly stumbled over this problem in the beginning. (The import command has the same problem, but it currently has no workaround.)

How about something like the attached patch? It assumes that if both the QUILT_PATCHES directory and the SERIES file have been found, the SUBDIR value can be trusted. Otherwise it generates an error, and the user must specify "-f" to create a new root in the current directory. This seems like it should be reliable, unless maybe QUILT_SERIES is set to an absolute path.

What do you think about making the users always specify "-f" for the first patch, to make sure they really want to create a new root in the current directory? That could be implemented with small modifications to this patch.

--
Joe Green <address@hidden>
MontaVista Software, Inc.
Source: MontaVista Software, Inc
Type: Enhancement
Description:
    Allow "new" or "import" in a SUBDIR only if the SERIES file exists,
    to be sure the root directory is correctly located.  Otherwise,
    allow the user to specify "-f" to create a new root in the current
    directory.

Index: quilt-0.34/quilt/new.in
===================================================================
--- quilt-0.34.orig/quilt/new.in        2004-07-09 07:26:33.000000000 +0000
+++ quilt-0.34/quilt/new.in     2004-07-12 02:33:47.000000000 +0000
@@ -19,12 +19,14 @@ fi
 
 usage()
 {
-       printf $"Usage: quilt new {patchname}\n"
+       printf $"Usage: quilt new [-f] {patchname}\n"
        if [ x$1 = x-h ]
        then
                printf $"
 Create a new patch with the specified file name, and insert it after the
 topmost patch in the patch series file.
+
+-f     Force creation of initial quilt tree root in the current directory.
 "
                exit 0
        else
@@ -32,7 +34,7 @@ topmost patch in the patch series file.
        fi
 }
 
-options=`getopt -o h -- "$@"`
+options=`getopt -o fh -- "$@"`
 
 if [ $? -ne 0 ]
 then
@@ -44,6 +46,9 @@ eval set -- "$options"
 while true
 do
        case "$1" in
+       -f)
+               opt_force=1
+               shift ;;
        -h)
                usage -h ;;
        --)
@@ -59,12 +64,16 @@ fi
 
 patch=${1#$QUILT_PATCHES/}
 
-if [ -n "$SUBDIR" ]
+if [ -n "$SUBDIR" -a ! -e "$SERIES" ]
 then
-       printf $"Warning: directory %s exists; ignoring\n" \
-              "$(echo $SUBDIR | sed -e 's:[^/]\+:..:g')$QUILT_PATCHES" >&2
-       cd $SUBDIR
-       unset SUBDIR
+       if [ "$opt_force" ] ; then
+               cd $SUBDIR
+               unset SUBDIR
+       else
+               printf $"Cannot locate root directory.  If this is the first 
patch,\n" >&2
+               printf $"use \"new -f\" to create a new root in the current 
directory.\n" >&2
+               exit 1
+       fi
 fi
 
 if patch_in_series $patch
Index: quilt-0.34/quilt/import.in
===================================================================
--- quilt-0.34.orig/quilt/import.in     2004-07-09 07:26:33.000000000 +0000
+++ quilt-0.34/quilt/import.in  2004-07-12 02:31:56.000000000 +0000
@@ -32,7 +32,8 @@ Import external patches.
        Patch filename to use inside quilt. This option can only be
        used when importing a single patch.
 
--f     Overwite/update existing patches.
+-f     Overwite/update existing patches, or force creation of initial
+       root directory.
 "
                exit 0
        else
@@ -75,6 +76,18 @@ then
        exit 1
 fi
 
+if [ -n "$SUBDIR" -a ! -e "$SERIES" ]
+then
+       if [ "$opt_force" ] ; then
+               cd $SUBDIR
+               unset SUBDIR
+       else
+               printf $"Cannot locate root directory.  If this is the first 
patch,\n" >&2
+               printf $"use \"import -f\" to create a new root in the current 
directory.\n" >&2
+               exit 1
+       fi
+fi
+
 [ -n "$opt_strip" ] && patch_args="-p$opt_strip"
 
 status=
Index: quilt-0.34/bash_completion
===================================================================
--- quilt-0.34.orig/bash_completion     2004-07-11 16:32:13.000000000 +0000
+++ quilt-0.34/bash_completion  2004-07-12 04:23:32.000000000 +0000
@@ -176,6 +176,7 @@ _quilt_completion()
           esac
           ;;
        new)
+          COMPREPLY=( $( compgen -W "-f -h" -- $cur ) )
           ;;
        next|previous)
           COMPREPLY=( $( compgen -W "-n $(quilt series)" -- $cur ) )

reply via email to

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