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