|
From: | Joe Green |
Subject: | Re: [Quilt-dev] Submit patch: allow "quilt delete" to delete patch files |
Date: | Fri, 12 Aug 2005 09:41:36 -0700 |
User-agent: | Mozilla Thunderbird 1.0.2 (X11/20050317) |
Jean Delvare wrote:I agree. I seriously considered calling it "--remove" but decided on "-r" for similar reasons. I think "--backup" is more likely to be set globally from QUILTRC, using either QUILT_DELETE_ARGS or QUILT_BACKUP.Or, since it's contradictory with the existance of --backup, maybe --remove, ie the long option only. After all, we can live with long options only, thanks to the completion ;)I don't think so. Not everyone uses bash completion or zsh. Thois option is likely to be typed often, as I can easily imagine that some users will want to use it for some of their patches and not the other ones (so it can't be set in QUILT_DELETE_OPTIONS). As quilt does seem to offer only one name (either long or short) for each option, I'd go with -r. The latter is the reason why "--backup" requires "-r" rather than being an alternative to it. I didn't want to introduce a silent change in the behavior of delete for people who are already using QUILT_BACKUP. This is also why "--backup" is silently ignored if "-r" is missing rather than generating a usage error. No objection. I've attached an updated version of the patch with this change.--backup Create a backup copy of a deleted patch file as patch~. Only supported when used with \"-r\".I think that this formulation is confusing. The operation of doing a backup copy of a file as you delete it has a name, it's called renaming a file. Additionally, the term "supported" doesn't quite fit here, as using --backup with -r will not trigger an error (nor do I think it should), it will simply have no effect. So I'd propose the following help text as a replacement: --backup Rename the patch file to patch~ rather than deleting it. Ignored if not used with \"-r\". -- Joe Green <address@hidden> MontaVista Software, Inc. |
Source: MontaVista Software, Inc. <address@hidden> Type: Enhancement Disposition: submitted to http://savannah.nongnu.org/projects/quilt Add options to the delete command that will remove the deleted patch from the QUILT_PATCHES directory and optionally create a backup file. Index: quilt-0.42/quilt/delete.in =================================================================== --- quilt-0.42.orig/quilt/delete.in +++ quilt-0.42/quilt/delete.in @@ -19,7 +19,7 @@ fi usage() { - printf $"Usage: quilt delete [patch | -n]\n" + printf $"Usage: quilt delete [-r] [--backup] [patch | -n]\n" if [ x$1 = x-h ] then printf $" @@ -29,6 +29,12 @@ topmost patch can be removed right now.) -n Delete the next patch after topmost, rather than the specified or topmost patch. + +-r Remove the deleted patch file from the patches directory as well. + +--backup + Rename the patch file to patch~ rather than deleting it. + Ignored if not used with \"-r\". " exit 0 @@ -37,7 +43,7 @@ topmost patch can be removed right now.) fi } -options=`getopt -o nh -- "$@"` +options=`getopt -o nrh --long backup -- "$@"` if [ $? -ne 0 ] then @@ -52,8 +58,14 @@ do -n) opt_next=1 shift ;; + -r) + opt_remove=1 + shift ;; -h) usage -h ;; + --backup) + QUILT_BACKUP=1 + shift ;; --) shift break ;; @@ -113,6 +125,28 @@ then printf $"Removed patch %s\n" "$(print_patch "$patch")" else printf $"Failed to remove patch %s\n" "$(print_patch "$patch")" >&2 + exit 1 +fi + +patch_file=$(patch_file_name "$patch") +if [ "$opt_remove" -a -e "$patch_file" ] +then + if [ "$QUILT_BACKUP" ] + then + if ! mv -f "$patch_file" "$patch_file~" + then + printf $"Failed to backup patch file \"%s\"\n" \ + "$patch_file" >&2 + exit 1 + fi + else + if ! rm -f "$patch_file" + then + printf $"Failed to remove patch file \"%s\"\n" \ + "$patch_file" >&2 + exit 1 + fi + fi fi ### Local Variables: ### mode: shell-script Index: quilt-0.42/bash_completion =================================================================== --- quilt-0.42.orig/bash_completion +++ quilt-0.42/bash_completion @@ -139,7 +139,7 @@ _quilt_completion() COMPREPLY=( $( compgen -W "-h $(quilt applied)" -- $cur ) ) ;; delete) - COMPREPLY=( $( compgen -W "-n -h $(quilt series)" -- $cur ) ) + COMPREPLY=( $( compgen -W "-n -r -h --backup $(quilt series)" -- $cur ) ) ;; diff) case $prev in
[Prev in Thread] | Current Thread | [Next in Thread] |