Don't suggest completions for git fork free-text arguments

The --remote-name and --org parameters to git fork expect arguments
which can be considered free text because the user has to suggest a
name, so we can't provide suggestions there.

If one of those two was the previous word then we clear completion
suggestions until a free-text word has been entered, allowing the user
to add their own input there.
This commit is contained in:
Siôn le Roux 2019-10-03 21:29:23 +02:00
Родитель 1a4bd7b974
Коммит 1d209b896f
1 изменённых файлов: 14 добавлений и 3 удалений

Просмотреть файл

@ -218,19 +218,30 @@ EOF
esac
}
# hub fork [--no-remote] [--remote-name] [--org]
# hub fork [--no-remote] [--remote-name REMOTE] [--org ORGANIZATION]
_git_fork() {
local i c=2 flags="--no-remote --remote-name --org"
while [ $c -lt $cword ]; do
i="${words[c]}"
case "$i" in
--no-remote|--remote-name|--org)
--remote-name|--org)
((c++))
flags=${flags/$i/}
;;
--no-remote)
flags=${flags/$i/}
;;
esac
((c++))
done
case "$prev" in
--remote-name|--org)
COMPREPLY=()
;;
*)
__gitcomp "$flags"
;;
esac
}
# hub pull-request [-f] [-m <MESSAGE>|-F <FILE>|-i <ISSUE>|<ISSUE-URL>] [-b <BASE>] [-h <HEAD>] [-a <USER>] [-M <MILESTONE>] [-l <LABELS>]