From f306221674af05422c9fd60410f2ab054e123255 Mon Sep 17 00:00:00 2001 From: Gastón Haro Date: Tue, 21 Jan 2020 21:39:29 -0300 Subject: github #46: Better restrict git-restore(1) file completions Add support to the -S and -W options. Remove the facility for completing files from the tree specified by the --source argument since, upon testing in git 2.26.0, that doesn't seem to be correct behaviour. (Note git-restore(1) says the command is experimental and its semantics may change.) See discussion on the PR for details. --- Completion/Unix/Command/_git | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'Completion/Unix') diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index 9a44ddbbe..15280db70 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -1567,13 +1567,17 @@ _git-restore() { case $state in pathspecs) - if [[ -z ${opt_args[(I)-s|--source|-S|--staged]} ]] && - # use index as a default base unless -S is specified - __git_ignore_line __git_modified_files + integer opt_S opt_W + [[ -n ${opt_args[(I)-S|--staged]} ]] && opt_S=1 + [[ -n ${opt_args[(I)-W|--worktree]} ]] && opt_W=1 + if (( opt_S && opt_W )) then - ret=0 + __git_ignore_line __git_changed_files && ret=0 + elif (( opt_S )) + then + __git_ignore_line __git_changed-in-index_files && ret=0 else - __git_ignore_line __git_tree_files ${PREFIX:-.} ${(Qv)opt_args[(i)-s|--source]:-HEAD} && ret=0 + __git_ignore_line __git_changed-in-working-tree_files && ret=0 fi ;; sources) -- cgit 1.4.1