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>

Cornelius Weig committed Feb 3, 2017 at 12:01 UTC cac84960ea5a3f97c52dae7bf05591237bc0303d
1 file changed +38 -7
contrib/completion/git-completion.bash
+38 -7
@@ -2384,24 +2384,55 @@ _git_config ()
2384
2385 _git_remote ()
2386 {
2387 - local subcommands="add rename remove set-head set-branches set-url show prune update"
2387 + local subcommands="
2388 + add rename remove set-head set-branches
2389 + get-url set-url show prune update
2390 + "
2391 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2392 if [ -z "$subcommand" ]; then
2390 - __gitcomp "$subcommands"
2393 + case "$cur" in
2394 + --*)
2395 + __gitcomp "--verbose"
2396 + ;;
2397 + *)
2398 + __gitcomp "$subcommands"
2399 + ;;
2400 + esac
2401 return
2402 fi
2403
2394 - case "$subcommand" in
2395 - rename|remove|set-url|show|prune)
2396 - __gitcomp_nl "$(__git_remotes)"
2404 + case "$subcommand,$cur" in
2405 + add,--*)
2406 + __gitcomp "--track --master --fetch --tags --no-tags --mirror="
2407 + ;;
2408 + add,*)
2409 + ;;
2410 + set-head,--*)
2411 + __gitcomp "--auto --delete"
2412 ;;
2398 - set-head|set-branches)
2413 + set-branches,--*)
2414 + __gitcomp "--add"
2415 + ;;
2416 + set-head,*|set-branches,*)
2417 __git_complete_remote_or_refspec
2418 ;;
2401 - update)
2419 + update,--*)
2420 + __gitcomp "--prune"
2421 + ;;
2422 + update,*)
2423 __gitcomp "$(__git_get_config_variables "remotes")"
2424 ;;
2425 + set-url,--*)
2426 + __gitcomp "--push --add --delete"
2427 + ;;
2428 + get-url,--*)
2429 + __gitcomp "--push --all"
2430 + ;;
2431 + prune,--*)
2432 + __gitcomp "--dry-run"
2433 + ;;
2434 *)
2435 + __gitcomp_nl "$(__git_remotes)"
2436 ;;
2437 esac
2438 }