threads / patch / 26987

patchgit-completion: Add support for git submodule options

Subject: [PATCH] git-completion: Add support for git submodule options

## tl;dr

One message between Apr 4, 2011 and Apr 4, 2011. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Nicolas Morey-Chaisemartin· Apr 4, 2011, 11:15 UTC · lore

Completion for git submodule only handled subcommands. Add support for options of each subcommand

Signed-off-by: Nicolas Morey-Chaisemartin <nicolas@morey-chaisemartin.com>
---
 contrib/completion/git-completion.bash |   38 +++++++++++++++++++++++++++++++-
 1 files changed, 37 insertions(+), 1 deletions(-)
Show changes to contrib/completion/git-completion.bash +37 −1
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
 }
 

← back to recent threads