From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 18675 invoked from network); 15 Mar 2023 23:59:55 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 15 Mar 2023 23:59:55 -0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Message-ID:Date:Content-ID: Content-Type:MIME-Version:Subject:To:From:Reply-To:Cc: Content-Transfer-Encoding:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References; bh=9Ybjd6uV2uSdI/etW4gIbOyT8BVNkUBc7F5+717TIHk=; b=CmZUPTPKzpBA5ro+3r+PQB2JY9 nVprlWSlGK+N6v/gFhyb1DLU3JwxNEESK25S9Y1auc6qpBl6IL0LnnW7KoPeD5TIgcdf0SrzflASN ovHCG7esW/N21h1A4PE9sfLICIzz14OAu7UrhkUdESFy52Ar3RC3v4rqZYmqnONp+VZ4Y5ZI8rFFe xW13Y8TeaxaKy81ay9JSaLD3ndt4oOKRrySTb3uWKQH4lR2Bt1OMYL8IHpQUqcRogMhIyjtOXXFUh h46n2r4T9fzb25HENQNYP3vLdVcF44ZEtJLnK78YFDXWk+kcKTzuZeWXc2ebGR+9KGlaxSPllwqzA Ch95d5Fg==; Received: by zero.zsh.org with local id 1pcb2B-000JWI-3c; Wed, 15 Mar 2023 23:59:55 +0000 Received: by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1pcb20-000JEL-1o; Wed, 15 Mar 2023 23:59:44 +0000 Received: from [192.168.178.21] (helo=hydra) by mail.kiddle.eu with esmtp(Exim 4.95) (envelope-from ) id 1pcb1z-000GcL-Fs for zsh-workers@zsh.org; Thu, 16 Mar 2023 00:59:43 +0100 From: Oliver Kiddle To: Zsh workers Subject: PATCH: update completion of git attributes MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <63877.1678924783.1@hydra> Date: Thu, 16 Mar 2023 00:59:43 +0100 Message-ID: <63880-1678924783.489110@winQ.QohW.b7Xr> X-Seq: 51583 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: This only affects completion for git check-attr so not exactly the most popular git subcommand. The git completion is more than a little out-of-date with regard to the list of attributes - it takes fairly close reading of gitattributes(5) to identify them all. It was possible to replace a loop with a use of the :| set difference operator that didn't exist when this was first written. Is a pity the rhs of that operator needs to be an array and can't be something like ${attributes%%:*}. I didn't like it listing -z twice with two descriptions. I've left it changing the description even though one description could adequately cover both input and output. --source is a new option in git 2.40 (released only yesterday). Oliver diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index 1a9c79034..1c3a95031 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -5866,46 +5866,51 @@ _git-upload-pack () { (( $+functions[_git-check-attr] )) || _git-check-attr () { - local z_opt= - - local curcontext=$curcontext state line ret=1 + local curcontext="$curcontext" z_opt ret=1 + local -a state line declare -A opt_args if (( words[(I)--stdin] )); then - z_opt='-z[paths are separated with NUL character when reading from stdin]' + z_opt='-z[terminate input file list and output records by a NUL character]' + else + z_opt='-z[separate output records with NUL character]' fi - _arguments -C \ - {-a,--all}'[list all attributes that are associated with the specified paths]' \ + _arguments -C $z_opt \ '--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 \ + '(--source)--cached[consider .gitattributes in the index only, ignoring the working tree]' \ + '(--cached)--source=[specify tree to scan for .gitattributes (useful in bare repo)]:tree object:__git_tree_ishs' \ + - files \ + '(-a --all --)'{-a,--all}'[list all attributes that are associated with the specified paths]' \ '(-)--[interpret preceding arguments as attributes and following arguments as path names]' \ - '*:: :->attribute-or-file' && ret=0 + '*: :__git_cached_files' \ + - attrs \ + '*:::attribute:->attributes' && ret=0 case $state in - (attribute-or-file) - local -a attributes - - attributes=(crlf ident filter diff merge) - - local only_attributes=1 - for (( i = 2; i < $#words; i++ )); do - if (( attributes[(I)$words[i]] == 0 )); then - only_attributes=0 - break - fi - done - - if (( !only_attributes )) || [[ -n ${opt_args[(I)--]} ]]; then - __git_cached_files && ret=0 - else - _alternative \ - 'attributes::__git_attributes' \ - 'files::__git_cached_files' && ret=0 - fi - ;; + attributes) + local -a attributes plain dedup + attributes=( + crlf:"line-ending convention (deprecated)" + text:"line-ending normalization" + eol:"line-ending style" + working-tree-encoding:"text encoding in working directory" + ident:'$Id$ substitution' + filter:"filters" + diff:"textual diff" + merge:"merging strategy" + conflict-marker-size:"length of markers left in the work tree" + whitespace:"control over what diff and apply should consider whitespace errors" + export-ignore:"exclude from archive files" + export-subst:"expand placeholders when adding to an archive" + delta:"don't attempt compression of blobs" + encoding:"character encoding that should be used by GUI tools" + ) + plain=( ${attributes%%:*} ) + dedup=( "${(@)words[1,CURRENT-1]}" ) + (( ! ${#dedup:|plain} )) && _describe -t git-attributes \ + attribute attributes -F dedup && ret=0 + ;; esac return ret @@ -6584,20 +6589,6 @@ __git_compression_levels () { '9:maximum compression' } -(( $+functions[__git_attributes] )) || -__git_attributes () { - local -a attributes - - attributes=( - 'crlf:line-ending convention' - 'ident:ident substitution' - 'filter:filters' - 'diff:textual diff' - 'merge:merging strategy') - - _describe -t attributes attribute attributes $* -} - (( $+functions[__git_daemon_service] )) || __git_daemon_service () { local -a services