From: Lee Marlow <lee.marlow@gmail.com>
To: "Shawn O. Pearce" <spearce@spearce.org>
Cc: git@vger.kernel.org, Lee Marlow <lee.marlow@gmail.com>
Subject: [PATCH] bash completion: Add completion for 'git help'
Date: Wed, 23 Jul 2008 18:08:32 -0600 [thread overview]
Message-ID: <1216858112-53713-1-git-send-email-lee.marlow@gmail.com> (raw)
In-Reply-To: <1216854795-51155-1-git-send-email-lee.marlow@gmail.com>
Renamed cached __git_commandlist to __git_porcelain_commandlist
and added __git_all_commandlist that only filters out *--* helpers.
Completions for 'git help' will use the __git_all_commandlist, while
__git_porcelain_commandlist is used for git command completion.
Users who actually read man pages may want to see help for plumbing
commands.
Options added: --all --info --man --web
Signed-off-by: Lee Marlow <lee.marlow@gmail.com>
---
This version fixes a small error in the __git_all_commands
contrib/completion/git-completion.bash | 46 +++++++++++++++++++++++++++-----
1 files changed, 39 insertions(+), 7 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 2edb341..f3bdea4 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -349,10 +349,10 @@ __git_complete_revlist ()
esac
}
-__git_commands ()
+__git_all_commands ()
{
- if [ -n "$__git_commandlist" ]; then
- echo "$__git_commandlist"
+ if [ -n "$__git_all_commandlist" ]; then
+ echo "$__git_all_commandlist"
return
fi
local i IFS=" "$'\n'
@@ -360,6 +360,24 @@ __git_commands ()
do
case $i in
*--*) : helper pattern;;
+ *) echo $i;;
+ esac
+ done
+}
+__git_all_commandlist=
+__git_all_commandlist="$(__git_all_commands 2>/dev/null)"
+
+__git_porcelain_commands ()
+{
+ if [ -n "$__git_porcelain_commandlist" ]; then
+ echo "$__git_porcelain_commandlist"
+ return
+ fi
+ local i IFS=" "$'\n'
+ for i in "help" $(__git_all_commands)
+ do
+ case $i in
+ *--*) : helper pattern;;
applymbox) : ask gittus;;
applypatch) : ask gittus;;
archimport) : import;;
@@ -427,8 +445,8 @@ __git_commands ()
esac
done
}
-__git_commandlist=
-__git_commandlist="$(__git_commands 2>/dev/null)"
+__git_porcelain_commandlist=
+__git_porcelain_commandlist="$(__git_porcelain_commands 2>/dev/null)"
__git_aliases ()
{
@@ -767,6 +785,18 @@ _git_gc ()
COMPREPLY=()
}
+_git_help ()
+{
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$cur" in
+ --*)
+ __gitcomp "--all --info --man --web"
+ return
+ ;;
+ esac
+ __gitcomp "$(__git_all_commands)"
+}
+
_git_ls_remote ()
{
__gitcomp "$(__git_remotes)"
@@ -1369,7 +1399,8 @@ _git ()
case "$i" in
--git-dir=*) __git_dir="${i#--git-dir=}" ;;
--bare) __git_dir="." ;;
- --version|--help|-p|--paginate) ;;
+ --version|-p|--paginate) ;;
+ --help) command="help"; break ;;
*) command="$i"; break ;;
esac
c=$((++c))
@@ -1389,7 +1420,7 @@ _git ()
--help
"
;;
- *) __gitcomp "$(__git_commands) $(__git_aliases)" ;;
+ *) __gitcomp "$(__git_porcelain_commands) $(__git_aliases)" ;;
esac
return
fi
@@ -1414,6 +1445,7 @@ _git ()
fetch) _git_fetch ;;
format-patch) _git_format_patch ;;
gc) _git_gc ;;
+ help) _git_help ;;
log) _git_log ;;
ls-remote) _git_ls_remote ;;
ls-tree) _git_ls_tree ;;
--
1.6.0.rc0.14.g95f8
prev parent reply other threads:[~2008-07-24 0:09 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-23 23:13 [PATCH] bash completion: Add completion for 'git help' Lee Marlow
2008-07-24 0:07 ` Lee Marlow
2008-07-25 20:40 ` Shawn O. Pearce
2008-07-25 21:02 ` Junio C Hamano
2008-07-26 8:24 ` fetch refspec foo/* matches foo* Jeff King
2008-07-26 8:33 ` Jeff King
2008-07-26 13:13 ` [PATCH] init: handle empty "template" parameter, was " Johannes Schindelin
2008-07-28 6:02 ` Jeff King
2008-07-28 6:13 ` Junio C Hamano
2008-07-28 6:16 ` Jeff King
2008-07-27 0:18 ` Junio C Hamano
2008-07-27 6:15 ` [PATCH] make sure parsed wildcard refspec ends with slash Junio C Hamano
2008-07-27 17:20 ` Daniel Barkalow
2008-07-28 5:41 ` Jeff King
2008-07-24 0:08 ` Lee Marlow [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1216858112-53713-1-git-send-email-lee.marlow@gmail.com \
--to=lee.marlow@gmail.com \
--cc=git@vger.kernel.org \
--cc=spearce@spearce.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).