completion: simplify completing 'git worktree' subcommands and options
The completion function for 'git worktree' uses separate but very similar case arms to complete --options for each subcommand. Combine these into a single case arm to avoid repetition. Note that after this change we won't complete 'git worktree remove's '--force' option, but that is consistent with our general stance on not offering '--force', as it should be used with care. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
367efd54b3
commit
3c86f6cde8
|
@ -2990,29 +2990,15 @@ _git_worktree ()
|
||||||
{
|
{
|
||||||
local subcommands="add list lock move prune remove unlock"
|
local subcommands="add list lock move prune remove unlock"
|
||||||
local subcommand="$(__git_find_on_cmdline "$subcommands")"
|
local subcommand="$(__git_find_on_cmdline "$subcommands")"
|
||||||
if [ -z "$subcommand" ]; then
|
|
||||||
|
case "$subcommand,$cur" in
|
||||||
|
,*)
|
||||||
__gitcomp "$subcommands"
|
__gitcomp "$subcommands"
|
||||||
else
|
;;
|
||||||
case "$subcommand,$cur" in
|
*,--*)
|
||||||
add,--*)
|
__gitcomp_builtin worktree_$subcommand
|
||||||
__gitcomp_builtin worktree_add
|
;;
|
||||||
;;
|
esac
|
||||||
list,--*)
|
|
||||||
__gitcomp_builtin worktree_list
|
|
||||||
;;
|
|
||||||
lock,--*)
|
|
||||||
__gitcomp_builtin worktree_lock
|
|
||||||
;;
|
|
||||||
prune,--*)
|
|
||||||
__gitcomp_builtin worktree_prune
|
|
||||||
;;
|
|
||||||
remove,--*)
|
|
||||||
__gitcomp "--force"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
__git_complete_common () {
|
__git_complete_common () {
|
||||||
|
|
Loading…
Reference in New Issue