git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Teach git-completion about git p4
@ 2012-09-21 21:51 Ryan Cumming
  2012-09-24 16:12 ` Junio C Hamano
  2012-09-26  0:48 ` Pete Wyckoff
  0 siblings, 2 replies; 3+ messages in thread
From: Ryan Cumming @ 2012-09-21 21:51 UTC (permalink / raw)
  To: git, gitster; +Cc: Ryan Cumming

From: Ryan Cumming <etaoins@gmail.com>

git p4 was moved out of contrib in 1.7.11 but it git-completion didn't
know about it. Add git p4 completion based on the existing SVN
completion. It covers all known subcommands and options except for the
-/ option for clone which doesn't use the standard -- prefix.

Signed-off-by: Ryan Cumming <etaoins@gmail.com>
---
 contrib/completion/git-completion.bash | 44 ++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index c48cd19..c6140be 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1459,6 +1459,50 @@ _git_notes ()
 	esac
 }
 
+_git_p4 ()
+{
+	local subcommands="
+		clone sync rebase submit
+		"
+	local subcommand="$(__git_find_on_cmdline "$subcommands")"
+	if [ -z "$subcommand" ]; then
+		__gitcomp "$subcommands"
+	else
+		local common_opts="--git-dir= --verbose"
+		local sync_opts="
+			--branch= --detect-branches --changes-file=
+			--silent --detect-labels --import-labels
+			--import-local --max-changes= --keep-path
+			--use-client-spec $common_opts
+			"
+		local clone_opts="
+			--destination= --bare $sync_opts
+			"
+		local submit_opts="
+			--origin= -M --preserve-user --export-labels
+			$common_opts
+			"
+
+		case "$subcommand,$cur" in
+		clone,--*)
+			__gitcomp "$clone_opts"
+			;;
+		sync,--*)
+			__gitcomp "$sync_opts"
+			;;
+		rebase,--*)
+			__gitcomp "$common_opts --import-labels"
+			;;
+		submit,--*)
+			__gitcomp "$submit_opts"
+			;;
+		submit,*)
+			__gitcomp "$(__git_refs)"
+			;;
+		esac
+	fi
+}
+
 _git_pull ()
 {
 	__git_complete_strategy && return
-- 
1.7.12.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-09-26  0:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-21 21:51 [PATCH] Teach git-completion about git p4 Ryan Cumming
2012-09-24 16:12 ` Junio C Hamano
2012-09-26  0:48 ` Pete Wyckoff

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).