From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9626 invoked by alias); 11 Nov 2016 10:01:38 -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: X-Seq: 39916 Received: (qmail 17173 invoked from network); 11 Nov 2016 10:01:37 -0000 X-Qmail-Scanner-Diagnostics: from out4-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(66.111.4.28):SA:0(-0.7/5.0):. Processed in 1.314897 secs); 11 Nov 2016 10:01:37 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=date:from:message-id:subject:to :x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=KlZ DTLUlFObiwhobnjwZi3i1xrI=; b=pZRNGn/VX2wJKUdkipl/2Dj0p8Z8ri/Eep1 Fu23B56eP/dLZWyvZusC9MkaxZPryVcBZhiKACsuvaB1NbG6bYHSDs0IWF+SN2Ik BwFAJLJGgdEInZqSrvrFZaowA7gTBXgCsi45tXhJ0yPBDuaRRMcPHq07bU9CpI4E 62laOnGI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=date:from:message-id:subject:to :x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s=smtpout; bh=Kl ZDTLUlFObiwhobnjwZi3i1xrI=; b=OBpYP/cYs1XBxALFWPh6wF+XZyEn8vKRK6 uZLPbCMsrW7fsprbnD0+zm/sypr9rJ73nZ5iMe4kqcIS0ZgeMc8d+pUKgnWr60Af 3j7JFScWF2gDzcuyNvvPjZOIGg4IAUjtdlIKxb28iyRBn3fecsAGMILed0ebob/D wNo1n/wQ4= X-ME-Sender: X-Sasl-enc: UNiC5IXmRklogi0pkJWRNnasg0ESVc+LwrNaOdAntzVG 1478858490 From: Daniel Shahaf To: zsh-workers@zsh.org Subject: [PATCH] _git: Complete options and values for -c. Date: Fri, 11 Nov 2016 09:59:14 +0000 Message-Id: <1478858354-8147-1-git-send-email-danielsh@fujitsu.shahaf.local2> X-Mailer: git-send-email 2.1.4 The "$@" in the option-names call is added in order to propagate the new (-S =) arguments. --- This bifurcates _git-config() in order to provide completion for % git -c % git -c foo= Cheers, Daniel Completion/Unix/Command/_git | 45 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index 5b9ecb9..5f4dd18 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -2028,7 +2028,7 @@ _tig () { (( $+functions[_git-config] )) || _git-config () { local name_arg value_arg - local curcontext=$curcontext state line expl ret=1 + local curcontext=$curcontext state line ret=1 declare -A opt_args if (( words[(I)--get-regexp] )); then @@ -2084,6 +2084,38 @@ _git-config () { '(-e --edit --bool --int --bool-or-int --path -z --null --name-only --show-origin)'{-e,--edit}'[open config file for editing]' \ '(2 3 --bool --int --bool-or-int --path -z --null --name-only --show-origin)--get-color[find color setting]: :->gettable-color-option' \ '(2 3 --bool --int --bool-or-int --path -z --null --name-only --show-origin)--get-colorbool[check if color should be used]: :->gettable-colorbool-option' && ret=0 + __git_config_option-or-value "$@" && ret=0 + return ret +} + +(( $+functions[__git_config_option] )) || +__git_config_option () { + local -A opt_args=() + local -a line=( ${words[CURRENT]%%=*} ) + local state=option + __git_config_option-or-value "$@" +} + +(( $+functions[__git_config_value] )) || +__git_config_value () { + local -A opt_args=() + local -a line=( ${words[CURRENT]%%=*} ${words[CURRENT]#*=} ) + local state=value + __git_config_option-or-value "$@" +} + +# Helper to _git-config(). May be called by other functions, too, provided +# that The caller has set $line, $state, and $opt_args as _git-config() would +# set them: +# +# - set $line[1] to the option name being completed (even if completing an +# option value). +# - set $opt_args to git-config(1) options, as set by _arguments in +# _git-config(). +# - set $state as _arguments in _git-config() would set it. +(( $+functions[__git_config_option-or-value] )) || +__git_config_option-or-value () { + local expl ret # TODO: Add support for merge.*. (merge driver), diff.*. (diff driver), and filter.*. (filter driver) options # (see gitattributes(5)). @@ -2840,7 +2872,7 @@ _git-config () { _describe -t option-names $label \ sections -M 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' -S . -- \ sections_and_options -M 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' -qS . -- \ - options -M 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' && ret=0 + options -M 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' "$@" && ret=0 ;; (gettable-option) _wanted git-options expl option compadd -M 'r:|.=* r:|=*' -a - git_present_options && ret=0 @@ -7473,7 +7505,7 @@ _git() { '(- :)--version[display version information]' \ '(- :)--help[display help message]' \ '-C[run as if git was started in given path]: :_directories' \ - '*-c[pass configuration parameter to command]:parameter' \ + '*-c[pass configuration parameter to command]: :->configuration' \ '--exec-path=-[path containing core git-programs]:: :_directories' \ '(: -)--man-path[print the manpath for the man pages for this version of Git and exit]' \ '(: -)--info-path[print the path where the info files are installed and exit]' \ @@ -7504,6 +7536,13 @@ _git() { fi fi ;; + (configuration) + if compset -P 1 '*='; then + __git_config_value + else + __git_config_option -S = + fi + ;; esac else _call_function ret _$service