Skip to content

Commit 8435b54

Browse files
spearceJunio C Hamano
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2e3a430 commit 8435b54

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

contrib/completion/git-completion.bash

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ __git_commands ()
235235
for i in $(git help -a|egrep '^ ')
236236
do
237237
case $i in
238+
add--interactive) : plumbing;;
238239
cat-file) : plumbing;;
239240
check-ref-format) : plumbing;;
240241
commit-tree) : plumbing;;
@@ -358,6 +359,19 @@ _git_apply ()
358359
COMPREPLY=()
359360
}
360361

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+
361375
_git_branch ()
362376
{
363377
local cur="${COMP_WORDS[COMP_CWORD]}"
@@ -786,6 +800,7 @@ _git ()
786800

787801
case "$command" in
788802
am) _git_am ;;
803+
add) _git_add ;;
789804
apply) _git_apply ;;
790805
branch) _git_branch ;;
791806
checkout) _git_checkout ;;
@@ -852,6 +867,7 @@ complete -o default -o nospace -F _git_log git-whatchanged
852867
# included the '.exe' suffix.
853868
#
854869
if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
870+
complete -o default -F _git_add git-add.exe
855871
complete -o default -F _git_apply git-apply.exe
856872
complete -o default -o nospace -F _git git.exe
857873
complete -o default -F _git_branch git-branch.exe

0 commit comments

Comments
 (0)