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 <szeder.dev@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

SZEDER Gábor committed Feb 3, 2017 at 03:48 UTC 7b329b9dab276d7a90141a1c9260a6943c9dd007
1 file changed +11
contrib/completion/git-completion.bash
+11
@@ -2808,6 +2808,17 @@ __git_main ()
2808 done
2809
2810 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
2822 case "$cur" in
2823 --*) __gitcomp "
2824 --paginate