diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | Completion/Unix/Command/_quilt | 425 |
2 files changed, 195 insertions, 234 deletions
diff --git a/ChangeLog b/ChangeLog index 1399e0776..35cacfcc1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-09-24 Oliver Kiddle <opk@zsh.org> + + * 33238: Completion/Unix/Command/_quilt: correct return values + 2014-09-24 Peter Stephenson <p.stephenson@samsung.com> * Eric Cook: 33224: Completion/Linux/Command/_btrfs: complete diff --git a/Completion/Unix/Command/_quilt b/Completion/Unix/Command/_quilt index 2ceb2ffaa..76dda222f 100644 --- a/Completion/Unix/Command/_quilt +++ b/Completion/Unix/Command/_quilt @@ -1,249 +1,206 @@ #compdef quilt -local -a tmp -local rc +local curcontext="$curcontext" state line +local help="(- : *)-h[show help information]" +local verbose='(-h)-v[verbose, more user friendly output]' +local color='(-h)--color=[use syntax coloring]:color:(always auto never)' +local pstyle='(-h)-p+[select patch style]:patch style:((0\:exclude\ top-level\ directory 1\:use\ .orig\ on\ top-level\ directory ab\:use\ a\ or\ b\ as\ top-level\ directory))' +local -a pform rcfile +pform=( + '(-U -c -C -h)-u[create a unified diff]' + '(-u -c -C -h)-U+[create a unified diff with num lines of context]:lines' + '(-u -U -C -h)-c[create a context diff]' + '(-u -U -c -h)-C+[create a context diff with num lines of context]:lines' +) +typeset -A opt_args -_quilt_applied () { - tmp=( ${(f)"$(quilt applied 2>&1)"} ) - rc=$? - if (( rc == 0 )); then - _wanted -V 'applied patches' expl 'patch' compadd "${tmp[@]}" - else - _message "No applied patches" - fi +_quilt_applied() { + local expl + _wanted -V patches expl patch compadd \ + ${(f)"$(_call_program patches quilt $rcfile applied)"} } -_quilt_series () { - _wanted -V 'patches' expl 'patch' compadd ${(f)"$(quilt series)"} +_quilt_series() { + local expl + _wanted -V patches expl 'patch' compadd \ + ${(f)"$(_call_program patches quilt $rcfile series)"} } -_quilt_unapplied () { - tmp=( ${(f)"$(quilt unapplied 2>&1)"} ) - rc=$? - if (( rc == 0 )); then - _wanted -V 'unapplied patches' expl 'patch' compadd "${tmp[@]}" - else - _message "No unapplied patches" - fi +_quilt_unapplied() { + local expl + _wanted -V patches expl 'unapplied patch' compadd \ + ${(f)"$(_call_program patches quilt $rcfile unapplied)"} } -_arguments \ - '--trace[Runs the command in bash trace mode]' \ - '--quiltrc[Use the specified configuration file]:files:_files' \ - '--version[Print the version number and exit]' \ +_arguments $help \ + '--trace[run the command in bash trace mode]' \ + '--quiltrc=[use the specified configuration file]:files:_files' \ + '--version[print the version number and exit]' \ ':quilt command:(add annotate applied delete diff edit files fold fork graph grep header import mail new next patches pop previous push refresh remove rename revert series setup snapshot top unapplied upgrade)' \ - '*::subcmd:->subcmd' && return 0 + '*:: :->subcmd' && return -case "$state" in (subcmd) - case "$words[1]" in - (add) - _arguments '-h' \ - '-P[Patch to add files to]:quilt series:_quilt_series' \ - '*:files:_files' - ;; - (annotate) - _arguments '-h' \ - '-P[Stop checking for changes at the specified rather than the topmost patch]:quilt series:_quilt_series' \ - ':files:_files' - ;; - (applied) - _arguments '-h' \ - ':quilt series:_quilt_series' - ;; - (delete) - _arguments '-h' \ - '-n[Delete the next patch after topmost]' \ - '-r[Remove the deleted patch file from the patches directory as well]' \ - '--backup[Rename the patch file to patch~ rather than deleting it]' \ - ':quilt series:_quilt_series' - ;; - (diff) - _arguments '-h' \ - '-p[Select a patch style]:quilt patch style:(0 1 ab)' \ - '-u[Create a unified diff]' \ - '-U[Create a unified diff with num lines of context]:quilt unified diff: ' \ - '-c[Create a context diff]' \ - '-C[Create a context diff with num lines of context]:quilt context diff: ' \ - '--no-timestamps[Do not include file timestamps in patch headers]' \ - '--no-index[Do not output Index: lines]' \ - '-z[Write to standard output the changes that have been made relative to the topmost or specified patch]' \ - '-R[Create a reverse diff]' \ - '-P[Create a diff for the specified patch]:quilt series:_quilt_series' \ - '--combine[Create a combined diff for all patches between this patch and the patch specified with -P]:quilt series:_quilt_series' \ - '--snapshot[Diff against snapshot]' \ - '--diff=[Use the specified utility for generating the diff]:quilt select diff utility:_command_names -e' \ - '--color=[Use syntax coloring]:quilt select color:(always auto never)' \ - '--sort[Sort files by their name]' \ - '*:files:_files' - ;; - (edit) - _arguments '-h' \ - '*:files:_files' - ;; - (files) - _arguments '-h' \ - '-a[List all files in all applied patches]' \ - '-l[Add patch name to output]' \ - '-v[Verbose, more user friendly output]' \ - '--combine[Create a listing for all patches between this patch and the topmost or specified patch]:quilt series:_quilt_series' \ - ':quilt series:_quilt_series' - ;; - (fold) - _arguments '-h' \ - '-R[Apply patch in reverse]' \ - '-q[Quiet operation]' \ - '-f[Force apply]' \ - '-p[The number of pathname components to strip]:quilt select strip-level: ' - ;; - (fork) - _arguments '-h' - ;; - (graph) - _arguments '-h' \ - '--all[Generate a graph including all applied patches and their dependencies]' \ - '--reduce[Eliminate transitive edges from the graph]' \ - '--lines[Compute dependencies by looking at the lines the patches modify]:quilt select lines: ' \ - '--edge-labels=files[Label graph edges with the file names that the adjacent patches modify]' \ - '-T ps[Directly produce a PostScript output file]' \ - ':quilt series:_quilt_series' - ;; - (grep) - _arguments '-h' - ;; - (header) - _arguments '-h' \ - '-a[Append the exiting patch header]' \ - '-r[Replace the exiting patch header]' \ - '-e[Edit the header in $EDITOR]' \ - '--strip-diffstat[Strip diffstat output from the header]' \ - '--strip-trailing-whitespace[Strip trailing whitespace at the end of lines of the header]' \ - '--backup[Create a backup copy of the old version of a patch as patch~]' \ - ':quilt series:_quilt_series' - ;; - (import) - _arguments '-h' \ - '-p[Number of directory levels to strip when applying]:quilt select strip-level: ' \ - '-R[Apply patch in reverse]' \ - '-P[Patch filename to use inside quilt]:quilt select patch filename: ' \ - '-f[Overwrite/update existing patches]' \ - '-d[When overwriting in existing patch, keep the old (o), all (a), or new (n) patch header]:quilt select patch:(a n o)' \ - '*:files:_files' - ;; - (mail) - _arguments '-h' \ - '-m[Text to use as the text in the introduction]:quilt select text: ' \ - '-M[Like the -m option, but read the introduction from file]:files:_files' \ - '--prefix[Use an alternate prefix in the bracketed part of the subjects generated]:quilt select prefix: ' \ - '--mbox[Store all messages in the specified file in mbox format]:files:_files' \ - '--send[Send the messages directly]' \ - '--sender[The envelope sender address to use]:quilt select sender: ' \ - '--from[From header]:quilt select from: ' \ - '--subject[Subject header]:quilt select subject: ' \ - '--to[Append a recipient to the To header]:quilt select to: ' \ - '--cc[Append a recipient to the Cc header]:quilt select cc: ' \ - '--bcc[Append a recipient to the Bcc header]:quilt select bcc: ' \ - '--signature[Append the specified signature to messages]:files:_files' \ - '--reply-to[Add the appropriate headers to reply to the specified message]:quilt select reply-to: ' \ - '*:quilt series:_quilt_series' - ;; - (new) - _arguments '-h' \ - '-p[Select a patch style]:quilt patch style:(0 1 ab)' - ;; - (next) - _arguments '-h' \ - ':quilt series:_quilt_series' - ;; - (patches) - _arguments '-h' \ - '-v[Verbose, more user friendly output]' \ - ':files:_files' - ;; - (pop) - _arguments '-h' \ - '-a[Remove all applied patches]' \ - '-f[Force remove]' \ - '-R[Always verify if the patch removes cleanly]' \ - '-q[Quiet operation]' \ - '-v[Verbose operation]' \ - ':quilt applied:_quilt_applied' - ;; - (previous) - _arguments '-h' \ - ':quilt series:_quilt_series' - ;; - (push) - _arguments '-h' \ - '-a[Apply all patches in the series file]' \ - '-q[Quiet operation]' \ - '-f[Force apply, even if the patch has rejects]' \ - '-v[Verbose operation]' \ - '--fuzz[Set the maximum fuzz factor]' \ - '--merge=[Merge the patch file into the original files]:quilt select merge:(merge diff3)' \ - '--leave-rejects[Leave around the reject files patch produced]' \ - '--color=[Use syntax coloring]:quilt select color:(always auto never)' \ - ':quilt unapplied:_quilt_unapplied' - ;; - (refresh) - _arguments '-h' \ - '-p[Select a patch style]:quilt patch style:(0 1 ab)' \ - '-u[Create a unified diff]' \ - '-U[Create a unified diff with num lines of context]:quilt unified diff: ' \ - '-c[Create a context diff]' \ - '-C[Create a context diff with num lines of context]:quilt context diff: ' \ - '-z[Create a new patch containing the changes instead of refreshing the topmost patch]:quilt select new patch name: ' \ - '--no-timestamps[Do not include file timestamps in patch headers]' \ - '--no-index[Do not output Index: lines]' \ - '--diffstat[Add a diffstat section to the patch header, or replace the existing diffstat section]' \ - '-f[Enforce refreshing of a patch that is not on top]' \ - '--backup[Create a backup copy of the old version of a patch as patch~]' \ - '--sort[Sort files by their name instead of preserving the original order]' \ - '--strip-trailing-whitespace[Strip trailing whitespace at the end of lines]' \ - ':quilt series:_quilt_series' - ;; - (remove) - _arguments '-h' \ - '-P[Patch to remove]:quilt series:_quilt_series' - ;; - (rename) - _arguments '-h' \ - '-P[Patch to rename]:quilt series:_quilt_series' - ;; - (revert) - _arguments '-h' \ - '-P[Revert changes in the named patch]:quilt series:_quilt_series' \ - '*:files:_files' - ;; - (series) - _arguments '-h' \ - '-v[Verbose, more user friendly output]' - ;; - (setup) - _arguments '-h' \ - '-d[Optional path prefix for the resulting source tree]:quilt select path-prefix: ' \ - '--sourcedir[Directory that contains the package sources]:quilt select package sources directory: ' \ - '-v[Verbose debug output]' \ - '--fuzz[Set the maximum fuzz factor]' \ - ':files:_files' - ;; - (snapshot) - _arguments '-h' \ - '-d[Remove current snapshot]' - ;; - (top) - _arguments '-h' - ;; - (unapplied) - _arguments '-h' \ - ':quilt series:_quilt_series' - ;; - (upgrade) - _arguments '-h' - ;; - (*) - ;; - esac +[[ -z $state ]] && return 1 +rcfile=( ${opt_args[--quiltrc]:+--quiltrc=${opt_args[--quiltrc]}} ) +case $words[1] in + add) + _arguments -S $help \ + '-P+[specify patch to add files to]:patch:_quilt_applied' \ + '*:files:_files' && return + ;; + annotate) + _arguments $help \ + '-P[stop checking for changes at the specified rather than the topmost patch]:patch:_quilt_series' \ + ':files:_files' && return + ;; + applied) _arguments $help ':quilt series:_quilt_series' && return ;; + delete) + _arguments -s $help \ + '(:)-n[delete the next patch after topmost]' \ + '-r[remove the deleted patch file from the patches directory as well]' \ + '--backup[rename the patch file to patch~ rather than deleting it]' \ + '(-n):patch:_quilt_series' && return + ;; + diff) + _arguments -s $help $pstyle $pform $color \ + "--no-timestamps[don't include file timestamps in patch headers]" \ + "--no-index[don't output Index: lines]" \ + '(-P --snapshot)-z[show changes relative to the topmost or specified patch]' \ + '-R[create a reverse diff]' \ + '(-z --snapshot)-P[create a diff for the specified patch]:patch:_quilt_series' \ + '--combine[create a combined diff for all patches between this patch and the patch specified with -P]:patch:_quilt_series' \ + '(-P -z)--snapshot[diff against snapshot]' \ + '--diff=[use the specified utility for generating the diff]:diff utility:_command_names -e' \ + '--sort[sort files by name]' \ + '*:files:_files' && return + ;; + edit) _arguments $help '*:files:_files' && return ;; + files) + _arguments -s $help $verbose \ + '-a[list all files in all applied patches]' \ + '-l[add patch name to output]' \ + '--combine[create a listing for all patches between this patch and the topmost or specified patch]::patch:_quilt_series' \ + ':patch:_quilt_series' && return + ;; + fold) + _arguments -s $help \ + '-R[apply patch in reverse]' \ + '-q[quiet operation]' \ + '-f[force apply]' \ + '-p+[specify number of pathname components to strip]:components to strip' && return + ;; + fork) _arguments $help ':patch name' && return ;; + graph) + _arguments $help \ + '--all[include all applied patches and their dependencies]' \ + '--reduce[eliminate transitive edges from the graph]' \ + '--lines=-[compute dependencies by looking at lines patches modify]::number of lines' \ + '--edge-labels=files[label graph edges with file names that adjacent patches modify]' \ + '-T ps[produce a PostScript output file]' \ + ':patch:_quilt_series' && return + ;; + grep) _grep && return ;; + header) + _arguments $help \ + '(-r -e -h)-a[append to existing patch header]' \ + '(-a -e -h)-r[replace existing patch header]' \ + '(-a -r -h)-e[edit the header in $EDITOR]' \ + '--strip-diffstat[strip diffstat output from the header]' \ + '--strip-trailing-whitespace[strip trailing whitespace at the end of lines of the header]' \ + '--backup[create backup copy of patch with tilde suffix]' \ + ':patch:_quilt_series' && return + ;; + import) + _arguments $help \ + '-p+[number of directory levels to strip when applying]:quilt select strip-level: ' \ + '-R[apply patch in reverse]' \ + '-P+[patch filename to use inside quilt]:quilt select patch filename: ' \ + '-f[overwrite/update existing patches]' \ + '-d+[header resolution when overwriting in existing patch]:resolution:((a\:all\ headers n\:new\ headers o\:old\ headers))' \ + '*:files:_files' && return + ;; + mail) + _arguments $help \ + '(-h -M)-m[introduction text to use]:introduction text' \ + '(-h -m)-M[read introduction text from file]:file:_files' \ + '--prefix=[use an alternate prefix in the bracketed part of the subjects generated]:quilt select prefix: ' \ + '--mbox=[store all messages in the specified file in mbox format]:files:_files' \ + '--send[send the messages directly]' \ + '--sender=[specify envelope sender address to use]:sender:_email_addresses -c' \ + '--from=[from header]:address:_email_addresses' \ + '--subject=[subject header]:subject' \ + '*--to=[append a recipient to the To header]:recipient:_email_addresses' \ + '*--cc=[append a recipient to the Cc header]:recipient:_email_addresses' \ + '*--bcc=[append a recipient to the Bcc header]:recipient:_email_addresses' \ + '--signature=[append specified signature file to messages]:files:_files' \ + '--reply-to=[add reply address to message]:address:_email_addresses' \ + '*:patch:_quilt_series' && return + ;; + new) _arguments $help $pstyle ':patch name' && return ;; + next) _arguments $help ':patch:_quilt_series' && return ;; + patches) _arguments -S $help $verbose $color '*:files:_files' && return ;; + pop) + _arguments -s $help $verbose \ + '-a[remove all applied patches]' \ + '-f[force remove]' \ + '-R[always verify if the patch removes cleanly]' \ + '-q[quiet operation]' \ + ':patch:_quilt_applied' && return + ;; + previous) _arguments $help ':patch:_quilt_series' && return ;; + push) + _arguments $help $verbose $color \ + '-a[apply all patches in the series file]' \ + '-q[quiet operation]' \ + '-f[force apply, even if the patch has rejects]' \ + '--fuzz=[set the maximum fuzz factor]:factor [2]' \ + '--merge=[merge the patch file into the original files]::merge scheme:(merge diff3)' \ + '--leave-rejects[leave around the reject files patch produced]' \ + ':quilt unapplied:_quilt_unapplied' && return + ;; + refresh) + _arguments -s $help $pstyle $pform \ + '-z-[create a new patch containing the changes instead of refreshing the topmost patch]::new patch name' \ + '--no-timestamps[do not include file timestamps in patch headers]' \ + '--no-index[do not output Index: lines]' \ + '--diffstat[add a diffstat section to the patch header, or replace the existing diffstat section]' \ + '-f[enforce refreshing of a patch that is not on top]' \ + '--backup[create a backup copy of the old version of a patch as patch~]' \ + '--sort[sort files by their name instead of preserving the original order]' \ + '--strip-trailing-whitespace[strip trailing whitespace at the end of lines]' \ + ':patch:_quilt_series' && return + ;; + remove) + _arguments $help \ + '-P[patch to remove]:patch:_quilt_series' \ + '*:file:_files' && return + ;; + rename) + _arguments $help \ + '(-h)-P[patch to rename]:patch:_quilt_series' \ + ':new name' && return + ;; + revert) + _arguments $help \ + '-P[revert changes in the named patch]:patch:_quilt_series' \ + '*:files:_files' && return + ;; + series) _arguments $help $verbose $color && return ;; + setup) + _arguments $help $verbose \ + '-d[specify path prefix for resulting source tree]:prefix:_files -W / -P /' \ + '--sourcedir[specify location of package sources]:directory:_directories' \ + '--fuzz=[set the maximum fuzz factor]:factor' \ + ':files:_files' && return + ;; + snapshot) _arguments $help '-d[only remove current snapshot]' && return ;; + unapplied) _arguments $help ':patch:_quilt_series' && return ;; + top|upgrade) _arguments $help && return ;; + *) + _default + return ;; esac + +return 1 |