Skip to content

Commit cac8496

Browse files
Cornelius Weiggitster
authored andcommitted
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>
1 parent 188fba1 commit cac8496

1 file changed

Lines changed: 38 additions & 7 deletions

File tree

contrib/completion/git-completion.bash

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2384,24 +2384,55 @@ _git_config ()
23842384

23852385
_git_remote ()
23862386
{
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+
"
23882391
local subcommand="$(__git_find_on_cmdline "$subcommands")"
23892392
if [ -z "$subcommand" ]; then
2390-
__gitcomp "$subcommands"
2393+
case "$cur" in
2394+
--*)
2395+
__gitcomp "--verbose"
2396+
;;
2397+
*)
2398+
__gitcomp "$subcommands"
2399+
;;
2400+
esac
23912401
return
23922402
fi
23932403

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"
23972412
;;
2398-
set-head|set-branches)
2413+
set-branches,--*)
2414+
__gitcomp "--add"
2415+
;;
2416+
set-head,*|set-branches,*)
23992417
__git_complete_remote_or_refspec
24002418
;;
2401-
update)
2419+
update,--*)
2420+
__gitcomp "--prune"
2421+
;;
2422+
update,*)
24022423
__gitcomp "$(__git_get_config_variables "remotes")"
24032424
;;
2425+
set-url,--*)
2426+
__gitcomp "--push --add --delete"
2427+
;;
2428+
get-url,--*)
2429+
__gitcomp "--push --all"
2430+
;;
2431+
prune,--*)
2432+
__gitcomp "--dry-run"
2433+
;;
24042434
*)
2435+
__gitcomp_nl "$(__git_remotes)"
24052436
;;
24062437
esac
24072438
}

0 commit comments

Comments
 (0)