completion: teach remote subcommands to complete options

Git-remote needs to complete remote names, its subcommands, and options
thereof. In addition to the existing subcommand and remote name
completion, do also complete the options

 - add: --track --master --fetch --tags --no-tags --mirror=
 - set-url: --push --add --delete
 - get-url: --push --all
 - prune: --dry-run

Signed-off-by: Cornelius Weig <cornelius.weig@tngtech.com>
Reviewed-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Cornelius Weig
2017-02-03 12:01:58 +01:00
committed by Junio C Hamano
parent 188fba1172
commit cac84960ea

View File

@ -2384,24 +2384,55 @@ _git_config ()
_git_remote () _git_remote ()
{ {
local subcommands="add rename remove set-head set-branches set-url show prune update" local subcommands="
add rename remove set-head set-branches
get-url set-url show prune update
"
local subcommand="$(__git_find_on_cmdline "$subcommands")" local subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then if [ -z "$subcommand" ]; then
case "$cur" in
--*)
__gitcomp "--verbose"
;;
*)
__gitcomp "$subcommands" __gitcomp "$subcommands"
;;
esac
return return
fi fi
case "$subcommand" in case "$subcommand,$cur" in
rename|remove|set-url|show|prune) add,--*)
__gitcomp_nl "$(__git_remotes)" __gitcomp "--track --master --fetch --tags --no-tags --mirror="
;; ;;
set-head|set-branches) add,*)
;;
set-head,--*)
__gitcomp "--auto --delete"
;;
set-branches,--*)
__gitcomp "--add"
;;
set-head,*|set-branches,*)
__git_complete_remote_or_refspec __git_complete_remote_or_refspec
;; ;;
update) update,--*)
__gitcomp "--prune"
;;
update,*)
__gitcomp "$(__git_get_config_variables "remotes")" __gitcomp "$(__git_get_config_variables "remotes")"
;; ;;
set-url,--*)
__gitcomp "--push --add --delete"
;;
get-url,--*)
__gitcomp "--push --all"
;;
prune,--*)
__gitcomp "--dry-run"
;;
*) *)
__gitcomp_nl "$(__git_remotes)"
;; ;;
esac esac
} }