Skip to content

Commit 7b329b9

Browse files
szedergitster
authored andcommitted
completion: don't offer commands when 'git --opt' needs an argument
The main git options '--git-dir', '-c', '-C', '--worktree' and '--namespace' require an argument, but attempting completion right after them lists git commands. Don't offer anything right after these options, thus let Bash fall back to filename completion, because - the three options '--git-dir', '-C' and '--worktree' do actually require a path argument, and - we don't complete the required argument of '-c' and '--namespace', and in that case the "standard" behavior of our completion script is to not offer anything, but fall back to filename completion. Signed-off-by: SZEDER Gábor <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 91b7ea8 commit 7b329b9

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

contrib/completion/git-completion.bash

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2808,6 +2808,17 @@ __git_main ()
28082808
done
28092809

28102810
if [ -z "$command" ]; then
2811+
case "$prev" in
2812+
--git-dir|-C|--work-tree)
2813+
# these need a path argument, let's fall back to
2814+
# Bash filename completion
2815+
return
2816+
;;
2817+
-c|--namespace)
2818+
# we don't support completing these options' arguments
2819+
return
2820+
;;
2821+
esac
28112822
case "$cur" in
28122823
--*) __gitcomp "
28132824
--paginate

0 commit comments

Comments
 (0)