bash: Complete long options to git-add.
The new --interactive mode of git-add can be very useful, so users will probably want to have completion for it. Likewise the new git-add--interactive executable is actually a plumbing command. Its invoked by `git add --interactive` and is not intended to be invoked directly by the user. Therefore we should hide it from the list of available Git commands. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Shawn O. Pearce committed
Feb 4, 2007 at 02:38 UTC
8435b548480a6b6d110fd2f59b3139f25ffb392e
1 file changed
+16
contrib/completion/git-completion.bash
+16
@@ -235,6 +235,7 @@ __git_commands ()
235
for i in $(git help -a|egrep '^ ')
236
do
237
case $i in
238
+ add--interactive) : plumbing;;
239
cat-file) : plumbing;;
240
check-ref-format) : plumbing;;
241
commit-tree) : plumbing;;
@@ -358,6 +359,19 @@ _git_apply ()
359
COMPREPLY=()
360
}
361
362
+_git_add ()
363
+{
364
+ local cur="${COMP_WORDS[COMP_CWORD]}"
365
+ case "$cur" in
366
+ --*)
367
+ COMPREPLY=($(compgen -W "
368
+ --interactive
369
+ " -- "$cur"))
370
+ return
371
+ esac
372
+ COMPREPLY=()
373
+}
374
+
375
_git_branch ()
376
{
377
local cur="${COMP_WORDS[COMP_CWORD]}"
@@ -786,6 +800,7 @@ _git ()
800
801
case "$command" in
802
am) _git_am ;;
803
+ add) _git_add ;;
804
apply) _git_apply ;;
805
branch) _git_branch ;;
806
checkout) _git_checkout ;;
@@ -852,6 +867,7 @@ complete -o default -o nospace -F _git_log git-whatchanged
867
# included the '.exe' suffix.
868
#
869
if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
870
+complete -o default -F _git_add git-add.exe
871
complete -o default -F _git_apply git-apply.exe
872
complete -o default -o nospace -F _git git.exe
873
complete -o default -F _git_branch git-branch.exe