Git fork

use enhanced basic regular expressions on macOS

When 1819ad327b (grep: fix multibyte regex handling under macOS,
2022-08-26) started to use the native regex library instead of Git's
own (compat/regex/), it lost support for alternation in basic
regular expressions.

Bring it back by enabling the flag REG_ENHANCED on macOS when
compiling basic regular expressions.

Reported-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com>
Suggested-by: Jeff King <peff@peff.net>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

René Scharfe and committed by
Junio C Hamano
54463d32 c48035d2

+24
+9
Makefile
··· 289 289 # Define NO_REGEX if your C library lacks regex support with REG_STARTEND 290 290 # feature. 291 291 # 292 + # Define USE_ENHANCED_BASIC_REGULAR_EXPRESSIONS if your C library provides 293 + # the flag REG_ENHANCED and you'd like to use it to enable enhanced basic 294 + # regular expressions. 295 + # 292 296 # Define HAVE_DEV_TTY if your system can open /dev/tty to interact with the 293 297 # user. 294 298 # ··· 2040 2044 ifdef NO_REGEX 2041 2045 COMPAT_CFLAGS += -Icompat/regex 2042 2046 COMPAT_OBJS += compat/regex/regex.o 2047 + else 2048 + ifdef USE_ENHANCED_BASIC_REGULAR_EXPRESSIONS 2049 + COMPAT_CFLAGS += -DUSE_ENHANCED_BASIC_REGULAR_EXPRESSIONS 2050 + COMPAT_OBJS += compat/regcomp_enhanced.o 2051 + endif 2043 2052 endif 2044 2053 ifdef NATIVE_CRLF 2045 2054 BASIC_CFLAGS += -DNATIVE_CRLF
+9
compat/regcomp_enhanced.c
··· 1 + #include "../git-compat-util.h" 2 + #undef regcomp 3 + 4 + int git_regcomp(regex_t *preg, const char *pattern, int cflags) 5 + { 6 + if (!(cflags & REG_EXTENDED)) 7 + cflags |= REG_ENHANCED; 8 + return regcomp(preg, pattern, cflags); 9 + }
+1
config.mak.uname
··· 147 147 FREAD_READS_DIRECTORIES = UnfortunatelyYes 148 148 HAVE_NS_GET_EXECUTABLE_PATH = YesPlease 149 149 CSPRNG_METHOD = arc4random 150 + USE_ENHANCED_BASIC_REGULAR_EXPRESSIONS = YesPlease 150 151 151 152 # Workaround for `gettext` being keg-only and not even being linked via 152 153 # `brew link --force gettext`, should be obsolete as of
+5
git-compat-util.h
··· 1336 1336 return regexec(preg, buf, nmatch, pmatch, eflags | REG_STARTEND); 1337 1337 } 1338 1338 1339 + #ifdef USE_ENHANCED_BASIC_REGULAR_EXPRESSIONS 1340 + int git_regcomp(regex_t *preg, const char *pattern, int cflags); 1341 + #define regcomp git_regcomp 1342 + #endif 1343 + 1339 1344 #ifndef DIR_HAS_BSD_GROUP_SEMANTICS 1340 1345 # define FORCE_DIR_SET_GID S_ISGID 1341 1346 #else