completion: complete general config vars in two steps
[gitweb.git] / contrib / completion / git-completion.bash
index e74d50a4b9b3f413c5eb5fdfa3f9699d59a83d4d..a6f55e856a14fe8d844b8ee419fcb72c8667039a 100644 (file)
@@ -1995,7 +1995,15 @@ __git_compute_config_vars ()
 
 _git_config ()
 {
-       case "$prev" in
+       local varname
+
+       if [ "${BASH_VERSINFO[0]:-0}" -ge 4 ]; then
+               varname="${prev,,}"
+       else
+               varname="$(echo "$prev" |tr A-Z a-z)"
+       fi
+
+       case "$varname" in
        branch.*.remote|branch.*.pushremote)
                __gitcomp_nl "$(__git_remotes)"
                return
@@ -2150,9 +2158,14 @@ _git_config ()
                __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur_"
                return
                ;;
+       *.*)
+               __git_compute_config_vars
+               __gitcomp "$__git_config_vars"
+               ;;
+       *)
+               __git_compute_config_vars
+               __gitcomp "$(echo "$__git_config_vars" | sed 's/\.[^ ]*/./g')"
        esac
-       __git_compute_config_vars
-       __gitcomp "$__git_config_vars"
 }
 
 _git_remote ()