git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Nicolas Morey-Chaisemartin <devel-git@morey-chaisemartin.com>
Date
Apr 11, 2011, 17:47 UTC
Message-ID
<4DA33EC8.5040704@morey-chaisemartin.com>

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

Signed-off-by: Nicolas Morey-Chaisemartin <nicolas@morey-chaisemartin.com>
---
Changes:
 - Inlined local variables listing options.
 contrib/completion/git-completion.bash |   32 +++++++++++++++++++++++++++++++-
 1 files changed, 31 insertions(+), 1 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 840ae38..20d0cf0 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,35 @@ _git_submodule ()
 			;;
 		esac
 		return
+	else
+	    local cur
+	    _get_comp_words_by_ref -n =: cur
+	    case "$subcommand,$cur" in
+		 add,--*)
+		     __gitcomp "--branch= --force --reference="
+		     ;;
+		 status,--*)
+		     __gitcomp "--cached --recursive"
+		     ;;
+		 update,--*)
+		     __gitcomp "--init --no-fetch --rebase --reference= --merge --recursive"
+		     ;;
+		 summary,--*)
+		     __gitcomp "--cached --files --summary-limit="
+		     ;;
+		 summary,*)
+		     __gitcomp "$(__git_refs)"
+		     ;;
+		 foreach,--*)
+		     __gitcomp "--recursive"
+		     ;;
+		 sync,*)
+		     COMPREPLY=()
+		     ;;
+		 *)
+		     COMPREPLY=()
+		     ;;
+	    esac 
 	fi
 }
 
Next: Jens Lehmann
Message 1 of 3 in “git-completion: Add support for git submodule options”
  1. git-completion: Add support for git submodule optionsNicolas Morey-Chaisemartin, Apr 11, 2011
  2. Jens LehmannApr 11, 2011
  3. SZEDER GáborApr 12, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.