git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[RFC] config --get-regexp: avoid rewriting regex patterns; consider REG_ICASE

From
Pushkar Singh <pushkarkumarsingh1970@gmail.com>
Date
Jan 28, 2026, 14:12 UTC
Message-ID
<CALE2CrQD11Qa+wGVhsF8JwkuwkLWkDf9kGvs1NM2dsYFuPgUKA@mail.gmail.com>
Hi,

While looking at builtin/config.c I noticed the following NEEDSWORK comment in get_value():

  /*
   * NEEDSWORK: this naive pattern lowercasing obviously does not
   * work for more complex patterns like "^[^.]*Foo.*".
   */

Currently, git config --get-regexp emulates case-insensitive matching by lowercasing parts of the user-provided regex before compiling it. This breaks valid regular expressions and makes it impossible to express more complex patterns.

For example:
  git config --add Foo.Bar baz
  git config --add foo.Baz qux
  git config --get-regexp '^[^.]*Foo.*'

does not behave as expected because the pattern is rewritten before regcomp().

POSIX regex also does not support inline modifiers like (?i), so users currently have no way to explicitly request case-insensitive matching.

The documentation says matching is performed against a canonicalized lowercase key, but the current implementation achieves this by modifying the regex itself.

Would it make sense to stop rewriting the pattern and instead use REG_ICASE when compiling the regex? This would preserve user-provided regexes, support more complex expressions, simplify the code, and eliminate the NEEDSWORK.

If this direction sounds reasonable, I’d be happy to follow up with a patch.

Thanks, Pushkar

Next: Jeff King
Message 1 of 3 in “[RFC] config --get-regexp: avoid rewriting regex patterns; consider REG_ICASE”
  1. Pushkar SinghJan 28, 2026
  2. Jeff KingJan 29, 2026
  3. Pushkar SinghJan 29, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.