completion: support case-insensitive config vars

Config variables are case-insensitive but this case/esac construct is case-sensitive by default. For bash v4, it'll be easy. For platforms that are stuck with older versions, we need an external command, but that is not that critical. And where this additional overhead matters the most is Windows, but luckily Git for Windows ships with Bash v4. Helped-by: SZEDER Gábor <szeder.dev@gmail.com> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed May 26, 2018 at 15:55 UTC bea2125928f4d6ddad34c6e651d4a9ec7ee5dd4e
1 file changed +9 -1
contrib/completion/git-completion.bash
+9 -1
@@ -1995,7 +1995,15 @@ __git_compute_config_vars ()
1995
1996 _git_config ()
1997 {
1998 - case "$prev" in
1998 + local varname
1999 +
2000 + if [ "${BASH_VERSINFO[0]:-0}" -ge 4 ]; then
2001 + varname="${prev,,}"
2002 + else
2003 + varname="$(echo "$prev" |tr A-Z a-z)"
2004 + fi
2005 +
2006 + case "$varname" in
2007 branch.*.remote|branch.*.pushremote)
2008 __gitcomp_nl "$(__git_remotes)"
2009 return