Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
RFC: [PATCH] Completion/Unix/Command/_git: replace a few "*::" with "*:"
- X-seq: zsh-workers 44078
- From: Daniel Hahler <genml+zsh-workers@xxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: RFC: [PATCH] Completion/Unix/Command/_git: replace a few "*::" with "*:"
- Date: Sun, 24 Feb 2019 14:58:54 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/simple; d=thequod.de; h= content-transfer-encoding:mime-version:x-mailer:message-id:date :date:subject:subject:from:from:received:received:received; s= postfix2; t=1551016739; bh=uI1ELDgH4w/idHmXFZN5C2pUWfio4iv7OC1Fb WYeI5Y=; b=G+DLxB2nMEV5z3Vle0jjzLrYh4HhPL6vODhQJJlrGIz3n+T6JmBI3 7vkOaIQRFpABv7VhEOmh9Qiqh6ka4GUpwAKbGWZj9MM3M2q+wYjE24LIEvHkqyzz 2g9Vp8I28rJVRt+EeZER5mRv+nRpQlaTYjetN547QFSpRZnFgP+ej8=
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
From: Daniel Hahler <git@xxxxxxxxxx>
When using "*::" with _arguments instead of "*:", it will not complete
options after args, e.g. with:
compdef -e '_arguments "-a[foo]" "--bar[bar]" "*:: :_files"' foo
"foo -a . -<tab>" does not complete --bar.
This causes `git checkout -b foo bar` to not complete options at the
end, e.g. "--no-track".
This patch changes some of the "*::" to "*:", but is not really tested
in detail. Mostly based on trying if "--help" worked after any arg.
---
Completion/Unix/Command/_git | 49 ++++++++++++++++--------------------
1 file changed, 22 insertions(+), 27 deletions(-)
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index b3e54f7f9..e7015f395 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -69,7 +69,7 @@ _git-add () {
'--ignore-errors[continue adding if an error occurs]' \
$ignore_missing \
'--chmod[override the executable bit of the listed files]:override:(-x +x)' \
- '*:: :->file' && return
+ '*: :->file' && return
case $state in
(file)
@@ -420,14 +420,14 @@ _git-bundle () {
(( $+functions[_git-check-ignore] )) ||
_git-check-ignore () {
- _arguments \
+ _arguments -S \
'(-q --quiet)'{-q,--quiet}'[do not output anything, just set exit status]' \
'(-v --verbose)'{-v,--verbose}'[output details about the matching pattern (if any) for each pathname]' \
'--stdin[read file names from stdin instead of from the command-line]' \
'-z[make output format machine-parseable and treat input-paths as NUL-separated with --stdin]' \
'(-n --non-matching)'{-n,--non-matching}'[show given paths which do not match any pattern]' \
'--no-index[do not look in the index when undertaking the checks]' \
- '*:: :_files'
+ '*: :_files'
}
(( $+functions[_git-check-mailmap] )) ||
@@ -449,7 +449,7 @@ _git-checkout () {
local curcontext=$curcontext state line ret=1
declare -A opt_args
- _arguments -C -s \
+ _arguments -C -S -s \
'(-q --quiet --progress)'{-q,--quiet}'[suppress progress reporting]' \
'(-f --force -m --merge --conflict --patch)'{-f,--force}'[force branch switch/ignore unmerged entries]' \
'(-q --quiet -2 --ours -3 --theirs --patch)'{-2,--ours}'[check out stage #2 for unmerged paths]' \
@@ -469,15 +469,10 @@ _git-checkout () {
'--recurse-submodules=-[control recursive updating of submodules]::checkout:__git_commits' \
'(-q --quiet)--progress[force progress reporting]' \
'(-)--[start file arguments]' \
- '*:: :->branch-or-tree-ish-or-file' && ret=0
+ '*: :->branch-or-tree-ish-or-file' && ret=0
case $state in
(branch-or-tree-ish-or-file)
- # TODO: Something about *:: brings us here when we complete at "-". I
- # guess that this makes sense in a way, as we might want to treat it as
- # an argument, but I can't find anything in the documentation about this
- # behavior.
- [[ $line[CURRENT] = -* ]] && return
if (( CURRENT == 1 )) && [[ -z $opt_args[(I)--] ]]; then
# TODO: Allow A...B
local \
@@ -759,7 +754,7 @@ _git-diff () {
__git_setup_diff_options
__git_setup_diff_stage_options
- _arguments -C -s \
+ _arguments -C -S -s \
$* \
$diff_options \
'(--exit-code)--quiet[disable all output]' \
@@ -767,7 +762,7 @@ _git-diff () {
'(--cached --staged)--no-index[show diff between two paths on the filesystem]' \
'(--cached --staged --no-index)'{--cached,--staged}'[show diff between index and named commit]' \
'(-)--[start file arguments]' \
- '*:: :->from-to-file' && ret=0
+ '*: :->from-to-file' && ret=0
case $state in
(from-to-file)
@@ -874,7 +869,7 @@ _git-fetch () {
\*{-o+,--server-option=}'[send specified string to the server when using protocol version 2]:option' \
'--negotiation-tip=[only report refs reachable from specified object to the server]:commit:__git_commits' \
'--filter=[object filtering]:filter:_git_rev-list_filters' \
- '*:: :->repository-or-group-or-refspec' && ret=0
+ '*: :->repository-or-group-or-refspec' && ret=0
case $state in
(repository-or-group-or-refspec)
@@ -983,7 +978,7 @@ _git-grep () {
declare -A opt_args
# TODO: Need to implement -<num> as a shorthand for -C<num>
- _arguments -C -A '-*' \
+ _arguments -C -S -A '-*' \
'(-O --open-files-in-pager --no-index)--cached[search blobs registered in index file instead of working tree]' \
'(--cached)--no-index[search files in current directory, not just tracked files]' \
'(--exclude-standard)--no-exclude-standard[search also in ignored files]' \
@@ -1029,7 +1024,7 @@ _git-grep () {
$pattern_operators \
'--all-match[all patterns must match]' \
': :_guard "^-*" pattern' \
- '*:: :->tree-or-file' && ret=0
+ '*: :->tree-or-file' && ret=0
# TODO: If --cached, --no-index, -O, or --open-files-in-pager was given,
# don't complete treeishs.
@@ -1236,7 +1231,7 @@ _git-mv () {
'-k[skip rename/move that would lead to errors]' \
'(-n --dry-run)'{-n,--dry-run}'[only show what would happen]' \
':source:__git_cached_files' \
- '*:: :->source-or-destination' && ret=0
+ '*: :->source-or-destination' && ret=0
case $state in
(source-or-destination)
@@ -1563,7 +1558,7 @@ _git-rm () {
'--cached[only remove files from the index]' \
'--ignore-unmatch[exit with 0 status even if no files matched]' \
'(-q --quiet)'{-q,--quiet}"[don't list removed files]" \
- '*:: :->file' && ret=0
+ '*: :->file' && ret=0
case $state in
(file)
@@ -1592,7 +1587,7 @@ _git-shortlog () {
'-w-[linewrap the output]:: :->wrap' \
$revision_options \
'(-)--[start file arguments]' \
- '*:: :->commit-range-or-file' && ret=0
+ '*: :->commit-range-or-file' && ret=0
case $state in
(wrap)
@@ -1650,7 +1645,7 @@ _git-show () {
$log_options \
$revision_options \
'(-q --quiet)'{-q,--quiet}'[suppress diff output]' \
- '*:: :->object' && ret=0
+ '*: :->object' && ret=0
case $state in
(object)
@@ -3511,7 +3506,7 @@ _git-prune () {
'--progress[show progress]' \
'--expire=[only expire loose objects older than specified date]: :__git_datetimes' \
'--exclude-promisor-objects[limit traversal to objects outside promisor packfiles]' \
- '*:: :__git_heads'
+ '*: :__git_heads'
}
(( $+functions[_git-reflog] )) ||
@@ -4869,7 +4864,7 @@ _git-update-index () {
'--fsmonitor-valid[mark files as fsmonitor valid]' \
'--no-fsmonitor-valid[clear fsmonitor valid bit]' \
$z_opt \
- '*:: :_files'
+ '*: :_files'
}
(( $+functions[_git-update-ref] )) ||
@@ -5066,7 +5061,7 @@ _git-ls-files () {
'--recurse-submodules[recurse through submodules]' \
'--abbrev=[set minimum SHA1 display-length]: :__git_guard_number length' \
'--debug[show debugging data]' \
- '*:: :_files'
+ '*: :_files'
}
(( $+functions[_git-ls-remote] )) ||
@@ -5103,7 +5098,7 @@ _git-ls-tree () {
'--full-name[output full path-names]' \
'(--full-name)--full-tree[do not limit listing to current working-directory]' \
': :__git_tree_ishs' \
- '*:: :->file' && ret=0
+ '*: :->file' && ret=0
case $state in
(file)
@@ -5172,7 +5167,7 @@ _git-rev-list () {
'( --bisect-vars --bisect-all)--bisect[show only middlemost commit object]' \
'(--bisect)--bisect-vars[same as --bisect, displaying shell-evalable code]' \
'(--bisect)--bisect-all[display all commit objects between included and excluded commits]' \
- '*:: :->commit-or-path' && ret=0
+ '*: :->commit-or-path' && ret=0
case $state in
(commit-or-path)
@@ -5460,14 +5455,14 @@ _git-check-attr () {
z_opt='-z[paths are separated with NUL character when reading from stdin]'
fi
- _arguments -C \
+ _arguments -C -S \
{-a,--all}'[list all attributes that are associated with the specified paths]' \
'--stdin[read file names from stdin instead of from command line]' \
'--cached[consider .gitattributes in the index only, ignoring the working tree.]' \
'-z[terminate input and output records by a NUL character]' \
$z_opt \
'(-)--[interpret preceding arguments as attributes and following arguments as path names]' \
- '*:: :->attribute-or-file' && ret=0
+ '*: :->attribute-or-file' && ret=0
case $state in
(attribute-or-file)
@@ -5542,7 +5537,7 @@ _git-mailsplit () {
'-d-[specify number of leading zeros]: :__git_guard_number precision' \
'-f-[skip the first N numbers]: :__git_guard_number' \
'--keep-cr[do not remove CR from lines ending with CR+LF]' \
- '*::mbox file:_files'
+ '*:mbox file:_files'
}
(( $+functions[_git-merge-one-file] )) ||
--
2.20.1
Messages sorted by:
Reverse Date,
Date,
Thread,
Author