Re: [PATCH 8/9] completion: support case-insensitive config vars just a bit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> config variable names are technically case-insensitive while this case
> construct is by default case-sensitive. Moving it to case-insensitive
> could be a lot more work.

Bash v4 supports the case modification expansion in the form of
${prev,,}.  Alas OSX (or older LTS/Enterprise Linux releases) ships
Bash v3.2, which doesn't yet support this syntax, and there is ZSH,
which doesn't understand it either (though I suspect it has its own
weird syntax for case modification).  Supporting them could look
something like this:

  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
  <....>

Not pretty, but I think the additional complexity and overhead is
acceptable.  Yeah, on some platforms/shells we would run an extra
command substitution and an external command, but I suppose on those
platforms the overhead of the extra processes is not that critical.
And where this additional overhead matters the most is Windows, but
luckily Git for Windows ships with Bash v4.


> Instead let's just accept the form that is
> more likely to show up in practice.
> 
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx>
> ---
>  contrib/completion/git-completion.bash | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index 8d3257c4de..e7829b5b24 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -2084,7 +2084,7 @@ __git_compute_config_vars ()
>  _git_config ()
>  {
>  	case "$prev" in
> -	branch.*.remote|branch.*.pushremote)
> +	branch.*.remote|branch.*.push[Rr]emote)
>  		__gitcomp_nl "$(__git_remotes)"
>  		return
>  		;;
> @@ -2096,7 +2096,7 @@ _git_config ()
>  		__gitcomp "false true preserve interactive"
>  		return
>  		;;
> -	remote.pushdefault)
> +	remote.push[Dd]efault)
>  		__gitcomp_nl "$(__git_remotes)"
>  		return
>  		;;
> @@ -2162,7 +2162,7 @@ _git_config ()
>  		__gitcomp "$__git_send_email_suppresscc_options"
>  		return
>  		;;
> -	sendemail.transferencoding)
> +	sendemail.transfer[Ee]ncoding)
>  		__gitcomp "7bit 8bit quoted-printable base64"
>  		return
>  		;;

'git help config' shows 'color.showBranch' and
'sendemail.aliasesfiletype' in camelCase as well.




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux