From 983060d5d12e44558913f4c9d7e03ddd4a69f408 Mon Sep 17 00:00:00 2001 From: Jun-ichi Takimoto Date: Tue, 8 Mar 2016 21:21:44 +0900 Subject: 38074: _git reset HEAD: complete only staged files --- Completion/Unix/Command/_git | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'Completion/Unix') diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index b7eaf2e49..7a459f1fb 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=$line[1] fi - __git_tree_files ${PREFIX:-.} $commit && ret=0 + if [[ $commit == HEAD ]]; then + __git_ignore_line __git_staged_files && ret=0 + else + __git_ignore_line __git_tree_files ${PREFIX:-.} $commit && ret=0 + fi ;; esac @@ -6131,6 +6135,29 @@ __git_tree_files () { _wanted files expl 'tree file' _multi_parts -f $compadd_opts -- / tree_files } +(( $+functions[__git_staged_files] )) || +__git_staged_files () { + local -a slist staged_files + local item expl i + + slist=(${(0)"$(_call_program staged-files git status -z -uno 2>/dev/null)"}) + __git_command_successful $pipestatus || return 1 + + for (( i = 1; i <= $#slist; ++i )) do + item=$slist[i] + if [[ $item == (DD|AA|U|?U)* ]]; then + continue #XXX skip unmerged files + elif [[ $item == R* ]]; then + staged_files+=( $item[4,-1] $slist[++i] ) + elif [[ $item == [ACDM]* ]]; then + staged_files+=( $item[4,-1] ) + fi + done + staged_files=( ${(0)"$(__git_files_relative ${(pj:\0:)staged_files})"} ) + + _wanted staged-files expl 'staged file' compadd "$@" -a - staged_files +} + # Repository Argument Types (( $+functions[__git_remote_repositories] )) || -- cgit 1.4.1