git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] Instruct git-completion.bash that we are in test mode
@ 2013-01-21 22:30 Jean-Noël AVILA
  2013-01-21 23:32 ` Junio C Hamano
  0 siblings, 1 reply; 15+ messages in thread
From: Jean-Noël AVILA @ 2013-01-21 22:30 UTC (permalink / raw)
  To: git

In test mode, git completion should only propose core commands.

Signed-off-by: Jean-Noel Avila <jn.avila@free.fr>
---

I reworked the patch so that the test argument is only evaluated
when sourcing the file and there is no environment clutter.

At least, "it works for me".

 contrib/completion/git-completion.bash | 8 +++++++-
 t/t9902-completion.sh                  | 2 +-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 14dd5e7..ac9fa65 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -531,10 +531,16 @@ __git_complete_strategy ()
 	return 1
 }
 
+if [ "x$1" != "xTEST" ]; then
+	__git_cmdlist () { git help -a|egrep '^  [a-zA-Z0-9]'; }
+else
+	__git_cmdlist () { git help -a| egrep -m 1 -B1000 PATH | egrep '^  [a-zA-Z0-9]'; }
+fi
+
 __git_list_all_commands ()
 {
 	local i IFS=" "$'\n'
-	for i in $(git help -a|egrep '^  [a-zA-Z0-9]')
+	for i in $(__git_cmdlist)
 	do
 		case $i in
 		*--*)             : helper pattern;;
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index 3cd53f8..51463b2 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -13,7 +13,7 @@ complete ()
 	return 0
 }
 
-. "$GIT_BUILD_DIR/contrib/completion/git-completion.bash"
+. "$GIT_BUILD_DIR/contrib/completion/git-completion.bash" TEST
 
 # We don't need this function to actually join words or do anything special.
 # Also, it's cleaner to avoid touching bash's internal completion variables.
-- 
1.8.1.1.271.g02f55e6

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

end of thread, other threads:[~2013-01-25 22:07 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-21 22:30 [RFC] Instruct git-completion.bash that we are in test mode Jean-Noël AVILA
2013-01-21 23:32 ` Junio C Hamano
2013-01-22  0:39   ` Jeff King
2013-01-22  4:31     ` Junio C Hamano
2013-01-22  8:04       ` Jean-Noël Avila
2013-01-22 16:31         ` Junio C Hamano
2013-01-24 23:07     ` [PATCH] t9902: protect test from stray build artifacts Junio C Hamano
2013-01-25  1:13       ` Jeff King
2013-01-25  2:59         ` Jonathan Nieder
2013-01-25  4:11         ` Junio C Hamano
2013-01-25  4:13           ` Jeff King
2013-01-25  4:19           ` Junio C Hamano
2013-01-25  4:23             ` Jeff King
2013-01-25 18:34               ` Junio C Hamano
2013-01-25 22:06                 ` Jeff King

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).