From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2881 invoked by alias); 3 Mar 2016 05:53:52 -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: 38074 Received: (qmail 16611 invoked from network); 3 Mar 2016 05:53:50 -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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.1 X-Biglobe-Sender: Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 6.6 \(1510\)) Subject: Re: _git-reset doesn't complete newly staged files From: "Jun T." In-Reply-To: <0FD99C66-391B-4971-ABD2-3595A0EB21CB@kba.biglobe.ne.jp> Date: Thu, 3 Mar 2016 14:07:12 +0900 Content-Transfer-Encoding: quoted-printable Message-Id: <234B98BE-D775-4068-AE44-81715F430E15@kba.biglobe.ne.jp> References: <0FD99C66-391B-4971-ABD2-3595A0EB21CB@kba.biglobe.ne.jp> To: "zsh-workers@zsh.org" X-Mailer: Apple Mail (2.1510) X-Biglobe-Spnum: 63895 In the case of % git reset HEAD the patch below tries to offer only staged files (including newly staged files which have never been committed). A new function __git_staged_files() ignores unmerged (conflicting) files, but I'm not sure this is correct or not. In the case of % git reset commit # commit is not HEAD I have no idea what to do, so I just added __git_ignore_line to the original code.=20 diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index b7eaf2e..7a459f1 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -1377,7 +1377,11 @@ _git-reset () { if [[ -n $line[1] ]] && __git_is_committish $line[1]; then commit=3D$line[1] fi - __git_tree_files ${PREFIX:-.} $commit && ret=3D0 + if [[ $commit =3D=3D HEAD ]]; then + __git_ignore_line __git_staged_files && ret=3D0 + else + __git_ignore_line __git_tree_files ${PREFIX:-.} $commit && ret=3D0= + fi ;; esac =20 @@ -6131,6 +6135,29 @@ __git_tree_files () { _wanted files expl 'tree file' _multi_parts -f $compadd_opts -- / = tree_files } =20 +(( $+functions[__git_staged_files] )) || +__git_staged_files () { + local -a slist staged_files + local item expl i + + slist=3D(${(0)"$(_call_program staged-files git status -z -uno = 2>/dev/null)"}) + __git_command_successful $pipestatus || return 1 + + for (( i =3D 1; i <=3D $#slist; ++i )) do + item=3D$slist[i] + if [[ $item =3D=3D (DD|AA|U|?U)* ]]; then + continue #XXX skip unmerged files + elif [[ $item =3D=3D R* ]]; then + staged_files+=3D( $item[4,-1] $slist[++i] ) + elif [[ $item =3D=3D [ACDM]* ]]; then + staged_files+=3D( $item[4,-1] ) + fi + done + staged_files=3D( ${(0)"$(__git_files_relative = ${(pj:\0:)staged_files})"} ) + + _wanted staged-files expl 'staged file' compadd "$@" -a - = staged_files +} + # Repository Argument Types =20 (( $+functions[__git_remote_repositories] )) ||