[PATCH] git-completion: Add support for git submodule options
From: Nicolas Morey-Chaisemartin <hidden>
Date: 2016-06-15 22:50:58
Subsystem:
the rest · Maintainer:
Linus Torvalds
Completion for git submodule only handled subcommands. Add support for options of each subcommand Signed-off-by: Nicolas Morey-Chaisemartin <redacted> --- contrib/completion/git-completion.bash | 38 +++++++++++++++++++++++++++++++- 1 files changed, 37 insertions(+), 1 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 840ae38..a7040e1 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash@@ -2546,7 +2546,8 @@ _git_submodule () __git_has_doubledash && return local subcommands="add status init update summary foreach sync" - if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then + local subcommand="$(__git_find_on_cmdline "$subcommands")" + if [ -z "$subcommand" ]; then local cur _get_comp_words_by_ref -n =: cur case "$cur" in
@@ -2558,6 +2559,41 @@ _git_submodule () ;; esac return + else + local add_opts="--branch= --force --reference=" + local status_opts="--cached --recursive" + local update_opts="--init --no-fetch --rebase --reference= --merge --recursive" + local summary_opts="--cached --files --summary-limit=" + local foreach_opts="--recursive" + + local cur + _get_comp_words_by_ref -n =: cur + case "$subcommand,$cur" in + add,--*) + __gitcomp "$add_opts" + ;; + status,--*) + __gitcomp "$status_opts" + ;; + update,--*) + __gitcomp "$update_opts" + ;; + summary,--*) + __gitcomp "$summary_opts" + ;; + summary,*) + __gitcomp "$(__git_refs)" + ;; + foreach,--*) + __gitcomp "$foreach_opts" + ;; + sync,*) + COMPREPLY=() + ;; + *) + COMPREPLY=() + ;; + esac fi }