completion: don't offer commands when 'git --opt' needs an argument
[gitweb.git] / contrib / completion / git-completion.bash
index f59755d0600336de48907a7dcf1064b601dc53c6..92231c66da38bc338ea28c003452af3187bcbdb2 100644 (file)
@@ -2808,6 +2808,17 @@ __git_main ()
        done
 
        if [ -z "$command" ]; then
+               case "$prev" in
+               --git-dir|-C|--work-tree)
+                       # these need a path argument, let's fall back to
+                       # Bash filename completion
+                       return
+                       ;;
+               -c|--namespace)
+                       # we don't support completing these options' arguments
+                       return
+                       ;;
+               esac
                case "$cur" in
                --*)   __gitcomp "
                        --paginate