In test mode, git completion should only propose core commands.
Signed-off-by: Jean-Noel Avila <[email protected]>
---
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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html