Skip to content

Commit 3632cfc

Browse files
ArjenLgitster
authored andcommitted
Use compatibility regex library for OSX/Darwin
The standard libc regex library on OSX does not support alternation in POSIX Basic Regular Expression mode. This breaks the diff.funcname functionality on OSX. To fix this, we use the GNU regex library which is already present in the compat/ diretory for the MinGW port. However, simply adding compat/ to the COMPAT_CFLAGS variable causes a conflict between the system fnmatch.h and the one present in compat/. To remedy this, move the regex and fnmatch functionality to their own subdirectories in compat/ so they can be included seperately. Signed-off-by: Arjen Laarhoven <[email protected]> Tested-by: Mike Ralphson <[email protected]> (AIX) Tested-by: Johannes Sixt <[email protected]> (MinGW) Signed-off-by: Junio C Hamano <[email protected]>
1 parent 971e628 commit 3632cfc

File tree

6 files changed

+10
-2
lines changed

6 files changed

+10
-2
lines changed

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,8 @@ ifeq ($(uname_S),Darwin)
626626
endif
627627
NO_STRLCPY = YesPlease
628628
NO_MEMMEM = YesPlease
629+
COMPAT_CFLAGS += -Icompat/regex
630+
COMPAT_OBJS += compat/regex/regex.o
629631
endif
630632
ifeq ($(uname_S),SunOS)
631633
NEEDS_SOCKET = YesPlease
@@ -750,10 +752,10 @@ ifneq (,$(findstring MINGW,$(uname_S)))
750752
NO_SVN_TESTS = YesPlease
751753
NO_PERL_MAKEMAKER = YesPlease
752754
NO_POSIX_ONLY_PROGRAMS = YesPlease
753-
COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -DNOGDI -Icompat
755+
COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -DNOGDI -Icompat -Icompat/regex -Icompat/fnmatch
754756
COMPAT_CFLAGS += -DSNPRINTF_SIZE_CORR=1
755757
COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
756-
COMPAT_OBJS += compat/mingw.o compat/fnmatch.o compat/regex.o compat/winansi.o
758+
COMPAT_OBJS += compat/mingw.o compat/fnmatch/fnmatch.o compat/regex/regex.o compat/winansi.o
757759
EXTLIBS += -lws2_32
758760
X = .exe
759761
gitexecdir = ../libexec/git-core
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

t/t4018-diff-funcname.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,10 @@ test_expect_success 'last regexp must not be negated' '
5757
test_must_fail git diff --no-index Beer.java Beer-correct.java
5858
'
5959

60+
test_expect_success 'alternation in pattern' '
61+
git config diff.java.funcname "^[ ]*\\(\\(public\\|static\\).*\\)$"
62+
git diff --no-index Beer.java Beer-correct.java |
63+
grep "^@@.*@@ public static void main("
64+
'
65+
6066
test_done

0 commit comments

Comments
 (0)