Skip to contentSkip to conversation

completion: complete git submodule subcommands

PATCH New Denton Liu 1 participant 1 message Jan 2, 2017

lore
Share & tools
lore

Denton Liu

author
#0 lore raw

PATCH 1/1 completion: complete git submodule subcommands

Allow git submodule subcommands to be completed. This allows the '--remote' in the command 'git submodule update --remote', for example, to be fully completed.

---
Hi Shawn, sorry this is my first contribution to a mailing-list based project. If I've done anything wrong, please let me know.

Thanks,

Denton Liu

---
 contrib/completion/git-completion.bash | 46 ++++++++++++++++++++++++++--------
 1 file changed, 35 insertions(+), 11 deletions(-)
contrib/completion/git-completion.bash +35 -11
index 21016bf8d..941fbdfe2 100644
@@ -2556,17 +2556,41 @@ _git_submodule ()
 	__git_has_doubledash && return
 
 	local subcommands="add status init deinit update summary foreach sync"
-	if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
-		case "$cur" in
-		--*)
-			__gitcomp "--quiet --cached"
-			;;
-		*)
-			__gitcomp "$subcommands"
-			;;
-		esac
-		return
-	fi
+	local subcommand="$(__git_find_on_cmdline "$subcommands")"
+
+	case "$subcommand,$cur" in
+	,--*)
+		__gitcomp "--quiet"
+		;;
+	,*)
+		__gitcomp "$subcommands --quiet"
+		;;
+	add,--*)
+		__gitcomp "--force --name --reference --depth"
+		;;
+	status,--*)
+		__gitcomp "--cached --recursive"
+		;;
+	deinit,--*)
+		__gitcomp "--force --all"
+		;;
+	update,--*)
+		__gitcomp "
+			--init --remote --no-fetch --no-recommended-shallow
+			--recommended-shallow --force --rebase --merge --reference
+			--depth --recursive --jobs
+			"
+		;;
+	summary,--*)
+		__gitcomp "--cached --files --summary-limit"
+		;;
+	summary,*)
+		__gitcomp_nl "$(__git_refs)"
+		;;
+	foreach,--*|sync,--*)
+		__gitcomp "--recursive"
+		;;
+	esac
 }
 
 _git_svn ()
Signature · 1 line
2.11.0