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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: Nicolas Morey-Chaisemartin <nicolas@xxxxxxxxxxxxxxxxxxxxxx>
---
 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
 }
 
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]