Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSZEDER Gábor <szeder.dev@gmail.com>2019-12-19 18:09:19 +0300
committerJunio C Hamano <gitster@pobox.com>2020-01-16 01:06:13 +0300
commit3c86f6cde85216808cddce9d4947de53d590474c (patch)
treea6493f50d750770cc546c8f2d9bb5c6cda56f8f8 /contrib
parent367efd54b34883889068255c370a4b9f079cec2d (diff)
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>
Diffstat (limited to 'contrib')
-rw-r--r--contrib/completion/git-completion.bash30
1 files changed, 8 insertions, 22 deletions
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 340d8defce..d06715996d 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2990,29 +2990,15 @@ _git_worktree ()
{
local subcommands="add list lock move prune remove unlock"
local subcommand="$(__git_find_on_cmdline "$subcommands")"
- if [ -z "$subcommand" ]; then
+
+ case "$subcommand,$cur" in
+ ,*)
__gitcomp "$subcommands"
- else
- case "$subcommand,$cur" in
- add,--*)
- __gitcomp_builtin worktree_add
- ;;
- list,--*)
- __gitcomp_builtin worktree_list
- ;;
- lock,--*)
- __gitcomp_builtin worktree_lock
- ;;
- prune,--*)
- __gitcomp_builtin worktree_prune
- ;;
- remove,--*)
- __gitcomp "--force"
- ;;
- *)
- ;;
- esac
- fi
+ ;;
+ *,--*)
+ __gitcomp_builtin worktree_$subcommand
+ ;;
+ esac
}
__git_complete_common () {