Subject: Bug#1037929: git grep fails with "Invalid collation character" for valid collation sequences in []

From: наб <[email-masked]>
Date: Wed, 14 Jun 2023 15:26:09 +0200

Package: git
Version: 1:2.39.2-1.1
Version: 1:2.40.1-1
Severity: normal

Dear Maintainer,

  $ git grep '[а-я]'
  fatal: command line, '[а-я]': Invalid collation character
and even
  nabijaczleweli@tarta:~/code/voreutils$ locale
  LANG=en_GB.UTF-8
  LANGUAGE=en_GB:en
  LC_CTYPE="en_GB.UTF-8"
  LC_NUMERIC="en_GB.UTF-8"
  LC_TIME="en_GB.UTF-8"
  LC_COLLATE="en_GB.UTF-8"
  LC_MONETARY="en_GB.UTF-8"
  LC_MESSAGES="en_GB.UTF-8"
  LC_PAPER="en_GB.UTF-8"
  LC_NAME="en_GB.UTF-8"
  LC_ADDRESS="en_GB.UTF-8"
  LC_TELEPHONE="en_GB.UTF-8"
  LC_MEASUREMENT="en_GB.UTF-8"
  LC_IDENTIFICATION="en_GB.UTF-8"
  LC_ALL=
  $ git grep '[а-я]'
  fatal: command line, '[а-я]': Invalid collation character
  $ LC_ALL=ru_RU.UTF-8 locale
  LANG=en_GB.UTF-8
  LANGUAGE=en_GB:en
  LC_CTYPE="ru_RU.UTF-8"
  LC_NUMERIC="ru_RU.UTF-8"
  LC_TIME="ru_RU.UTF-8"
  LC_COLLATE="ru_RU.UTF-8"
  LC_MONETARY="ru_RU.UTF-8"
  LC_MESSAGES="ru_RU.UTF-8"
  LC_PAPER="ru_RU.UTF-8"
  LC_NAME="ru_RU.UTF-8"
  LC_ADDRESS="ru_RU.UTF-8"
  LC_TELEPHONE="ru_RU.UTF-8"
  LC_MEASUREMENT="ru_RU.UTF-8"
  LC_IDENTIFICATION="ru_RU.UTF-8"
  LC_ALL=ru_RU.UTF-8
  $ LC_ALL=ru_RU.UTF-8 git grep '[а-я]'
  fatal: command line, '[а-я]': Invalid collation character

This ought to match the entire modern russian alphabet,
and correctly does so under GNU grep and glibc regcomp(3)
on bookworm and sid.

I don't really see how а or я are "invalid" here;
oddly, git grep does accept '[ая]' &c.

Best,
наб

-- System Information:
Debian Release: 12.0
  APT prefers stable-security
  APT policy: (500, 'stable-security'), (500, 'stable-debug'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 6.1.0-9-amd64 (SMP w/24 CPU threads; PREEMPT)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_FIRMWARE_WORKAROUND, TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), LANGUAGE=en_GB:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages git depends on:
ii  git-man          1:2.39.2-1.1
ii  libc6            2.36-9
ii  libcurl3-gnutls  7.88.1-10
ii  liberror-perl    0.17029-2
ii  libexpat1        2.5.0-1
ii  libpcre2-8-0     10.42-1
ii  perl             5.36.0-7
ii  zlib1g           1:1.2.13.dfsg-1

Versions of packages git recommends:
ii  ca-certificates              20230311
ii  less                         590-2
ii  openssh-client [ssh-client]  1:9.2p1-2
ii  patch                        2.7.6-7

Versions of packages git suggests:
ii  gettext-base                          0.21-12
pn  git-cvs                               <none>
pn  git-daemon-run | git-daemon-sysvinit  <none>
pn  git-doc                               <none>
pn  git-email                             <none>
pn  git-gui                               <none>
pn  git-mediawiki                         <none>
pn  git-svn                               <none>
pn  gitk                                  <none>
pn  gitweb                                <none>

-- no debconf information