Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
bash completion: Add completion for 'git help'
author
Lee Marlow
<lee.marlow@gmail.com>
Thu, 24 Jul 2008 00:07:23 +0000
(18:07 -0600)
committer
Junio C Hamano
<gitster@pobox.com>
Sun, 27 Jul 2008 21:14:01 +0000
(14:14 -0700)
Rename cached __git_commandlist to __git_porcelain_commandlist and
add __git_all_commandlist that only filters out *--* helpers.
Completions for 'git help' will use the __git_all_commandlist, while
the __git_porcelain_commandlist is used for git command completion.
Users who actually read man pages may want to see help for plumbing
commands.
Signed-off-by: Lee Marlow <lee.marlow@gmail.com>
Acked-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/completion/git-completion.bash
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
6bb9e51
)
diff --git
a/contrib/completion/git-completion.bash
b/contrib/completion/git-completion.bash
index 2fb88a8feff5dbfa368785e8872b42742b257eec..30d870187e64e33ed430dc1fab1ea37036a07f58 100755
(executable)
--- a/
contrib/completion/git-completion.bash
+++ b/
contrib/completion/git-completion.bash
@@
-349,14
+349,32
@@
__git_complete_revlist ()
esac
}
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'
for i in $(git help -a|egrep '^ ')
return
fi
local i IFS=" "$'\n'
for i in $(git help -a|egrep '^ ')
+ 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;;
do
case $i in
*--*) : helper pattern;;
@@
-427,8
+445,8
@@
__git_commands ()
esac
done
}
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 ()
{
__git_aliases ()
{
@@
-778,6
+796,18
@@
_git_gc ()
COMPREPLY=()
}
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)"
_git_ls_remote ()
{
__gitcomp "$(__git_remotes)"
@@
-1410,7
+1440,8
@@
_git ()
case "$i" in
--git-dir=*) __git_dir="${i#--git-dir=}" ;;
--bare) __git_dir="." ;;
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))
*) command="$i"; break ;;
esac
c=$((++c))
@@
-1430,7
+1461,7
@@
_git ()
--help
"
;;
--help
"
;;
- *) __gitcomp "$(__git_commands) $(__git_aliases)" ;;
+ *) __gitcomp "$(__git_
porcelain_
commands) $(__git_aliases)" ;;
esac
return
fi
esac
return
fi
@@
-1455,6
+1486,7
@@
_git ()
fetch) _git_fetch ;;
format-patch) _git_format_patch ;;
gc) _git_gc ;;
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 ;;
log) _git_log ;;
ls-remote) _git_ls_remote ;;
ls-tree) _git_ls_tree ;;