From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 7b389006 for ; Sun, 24 Feb 2019 13:59:55 +0000 (UTC) Received: (qmail 28854 invoked by alias); 24 Feb 2019 13:59:37 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 44078 Received: (qmail 13295 invoked by uid 1010); 24 Feb 2019 13:59:37 -0000 X-Qmail-Scanner-Diagnostics: from hahler.de by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.100.2/25112. spamassassin: 3.4.2. Clear:RC:0(188.40.33.212):SA:0(-1.9/5.0):. Processed in 1.80138 secs); 24 Feb 2019 13:59:37 -0000 X-Envelope-From: daniel@hahler.de X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.hahler.de designates 188.40.33.212 as permitted sender) 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= From: Daniel Hahler To: zsh-workers@zsh.org Subject: RFC: [PATCH] Completion/Unix/Command/_git: replace a few "*::" with "*:" Date: Sun, 24 Feb 2019 14:58:54 +0100 Message-Id: <20190224135854.3905-1-genml+zsh-workers@thequod.de> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Qmail-Scanner-2.11: added fake Content-Type header Content-Type: text/plain From: Daniel Hahler 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 . -" 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 - as a shorthand for -C - _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