Code

Merge branch 'jj/icase-directory'
authorJunio C Hamano <gitster@pobox.com>
Sat, 4 Dec 2010 00:10:34 +0000 (16:10 -0800)
committerJunio C Hamano <gitster@pobox.com>
Sat, 4 Dec 2010 00:10:34 +0000 (16:10 -0800)
* jj/icase-directory:
  Support case folding in git fast-import when core.ignorecase=true
  Support case folding for git add when core.ignorecase=true
  Add case insensitivity support when using git ls-files
  Add case insensitivity support for directories when using git status
  Case insensitivity support for .gitignore via core.ignorecase
  Add string comparison functions that respect the ignore_case variable.
  Makefile & configure: add a NO_FNMATCH_CASEFOLD flag
  Makefile & configure: add a NO_FNMATCH flag

Conflicts:
Makefile
config.mak.in
configure.ac
fast-import.c

1  2 
Makefile
config.mak.in
configure.ac
dir.c
fast-import.c
read-cache.c

diff --cc Makefile
index 1d4241346594e5e0df7df7f766899d4ac76d84ff,8407c38407640d2c4768bbbaa9d79275b4ba9526..29ebe70599aa9c01ddb84e5611ac08d441adef4c
+++ b/Makefile
@@@ -68,8 -68,11 +68,13 @@@ all:
  #
  # Define NO_MKSTEMPS if you don't have mkstemps in the C library.
  #
 +# Define NO_STRTOK_R if you don't have strtok_r in the C library.
 +#
+ # Define NO_FNMATCH if you don't have fnmatch in the C library.
+ #
+ # Define NO_FNMATCH_CASEFOLD if your fnmatch function doesn't have the
+ # FNM_CASEFOLD GNU extension.
+ #
  # Define NO_LIBGEN_H if you don't have libgen.h.
  #
  # Define NEEDS_LIBGEN if your libgen needs -lgen when linking
@@@ -1054,7 -1041,7 +1060,8 @@@ ifeq ($(uname_S),Windows
        NO_UNSETENV = YesPlease
        NO_STRCASESTR = YesPlease
        NO_STRLCPY = YesPlease
 +      NO_STRTOK_R = YesPlease
+       NO_FNMATCH = YesPlease
        NO_MEMMEM = YesPlease
        # NEEDS_LIBICONV = YesPlease
        NO_ICONV = YesPlease
        AR = compat/vcbuild/scripts/lib.pl
        CFLAGS =
        BASIC_CFLAGS = -nologo -I. -I../zlib -Icompat/vcbuild -Icompat/vcbuild/include -DWIN32 -D_CONSOLE -DHAVE_STRING_H -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE
-       COMPAT_OBJS = compat/msvc.o compat/fnmatch/fnmatch.o compat/winansi.o compat/win32/pthread.o compat/win32/syslog.o compat/win32/sys/poll.o
-       COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DNOGDI -DHAVE_STRING_H -DHAVE_ALLOCA_H -Icompat -Icompat/fnmatch -Icompat/regex -Icompat/fnmatch -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
 -      COMPAT_OBJS = compat/msvc.o compat/winansi.o compat/win32/pthread.o
++      COMPAT_OBJS = compat/msvc.o compat/winansi.o compat/win32/pthread.o compat/win32/syslog.o compat/win32/sys/poll.o
+       COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DNOGDI -DHAVE_STRING_H -DHAVE_ALLOCA_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
        BASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -SUBSYSTEM:CONSOLE -NODEFAULTLIB:MSVCRT.lib
        EXTLIBS = advapi32.lib shell32.lib wininet.lib ws2_32.lib
        PTHREAD_LIBS =
@@@ -1128,7 -1096,7 +1135,8 @@@ ifneq (,$(findstring MINGW,$(uname_S))
        NO_UNSETENV = YesPlease
        NO_STRCASESTR = YesPlease
        NO_STRLCPY = YesPlease
 +      NO_STRTOK_R = YesPlease
+       NO_FNMATCH = YesPlease
        NO_MEMMEM = YesPlease
        NEEDS_LIBICONV = YesPlease
        OLD_ICONV = YesPlease
        NO_REGEX = YesPlease
        NO_PYTHON = YesPlease
        BLK_SHA1 = YesPlease
-       COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -DNOGDI -Icompat -Icompat/fnmatch -Icompat/win32
 +      ETAGS_TARGET = ETAGS
 +      NO_INET_PTON = YesPlease
 +      NO_INET_NTOP = YesPlease
 +      NO_POSIX_GOODIES = UnfortunatelyYes
+       COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -DNOGDI -Icompat -Icompat/win32
        COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
-       COMPAT_OBJS += compat/mingw.o compat/fnmatch/fnmatch.o compat/winansi.o \
 -      COMPAT_OBJS += compat/mingw.o compat/winansi.o compat/win32/pthread.o
++      COMPAT_OBJS += compat/mingw.o compat/winansi.o \
 +              compat/win32/pthread.o compat/win32/syslog.o \
 +              compat/win32/sys/poll.o
        EXTLIBS += -lws2_32
        PTHREAD_LIBS =
        X = .exe
@@@ -1360,10 -1326,17 +1368,21 @@@ endi
  ifdef NO_STRTOULL
        COMPAT_CFLAGS += -DNO_STRTOULL
  endif
 +ifdef NO_STRTOK_R
 +      COMPAT_CFLAGS += -DNO_STRTOK_R
 +      COMPAT_OBJS += compat/strtok_r.o
 +endif
+ ifdef NO_FNMATCH
+       COMPAT_CFLAGS += -Icompat/fnmatch
+       COMPAT_CFLAGS += -DNO_FNMATCH
+       COMPAT_OBJS += compat/fnmatch/fnmatch.o
+ else
+ ifdef NO_FNMATCH_CASEFOLD
+       COMPAT_CFLAGS += -Icompat/fnmatch
+       COMPAT_CFLAGS += -DNO_FNMATCH_CASEFOLD
+       COMPAT_OBJS += compat/fnmatch/fnmatch.o
+ endif
+ endif
  ifdef NO_SETENV
        COMPAT_CFLAGS += -DNO_SETENV
        COMPAT_OBJS += compat/setenv.o
diff --cc config.mak.in
index a0c34eec15773f0f3e4d2b4e12f0c76e722ede95,e4c3f569a30b6addb097d6d412e0744bcf886e64..56343bab505b59289d0a5334a2a6ac840d3f10d1
@@@ -46,7 -46,8 +46,9 @@@ NO_IPV6=@NO_IPV6
  NO_C99_FORMAT=@NO_C99_FORMAT@
  NO_HSTRERROR=@NO_HSTRERROR@
  NO_STRCASESTR=@NO_STRCASESTR@
 +NO_STRTOK_R=@NO_STRTOK_R@
+ NO_FNMATCH=@NO_FNMATCH@
+ NO_FNMATCH_CASEFOLD=@NO_FNMATCH_CASEFOLD@
  NO_MEMMEM=@NO_MEMMEM@
  NO_STRLCPY=@NO_STRLCPY@
  NO_UINTMAX_T=@NO_UINTMAX_T@
diff --cc configure.ac
index c5bc9a05f3730dc42f6a0dbf35551107886d7b0c,cbca4c763a9b005266f8818a5eafb9bb6f7903f6..33dd46262bfb7e6d9db80446fa06ff0ba819f5df
@@@ -824,12 -783,34 +824,40 @@@ GIT_CHECK_FUNC(strcasestr
  [NO_STRCASESTR=YesPlease])
  AC_SUBST(NO_STRCASESTR)
  #
 +# Define NO_STRTOK_R if you don't have strtok_r
 +GIT_CHECK_FUNC(strtok_r,
 +[NO_STRTOK_R=],
 +[NO_STRTOK_R=YesPlease])
 +AC_SUBST(NO_STRTOK_R)
 +#
+ # Define NO_FNMATCH if you don't have fnmatch
+ GIT_CHECK_FUNC(fnmatch,
+ [NO_FNMATCH=],
+ [NO_FNMATCH=YesPlease])
+ AC_SUBST(NO_FNMATCH)
+ #
+ # Define NO_FNMATCH_CASEFOLD if your fnmatch function doesn't have the
+ # FNM_CASEFOLD GNU extension.
+ AC_CACHE_CHECK([whether the fnmatch function supports the FNMATCH_CASEFOLD GNU extension],
+  [ac_cv_c_excellent_fnmatch], [
+ AC_EGREP_CPP(yippeeyeswehaveit,
+       AC_LANG_PROGRAM([
+ #include <fnmatch.h>
+ ],
+ [#ifdef FNM_CASEFOLD
+ yippeeyeswehaveit
+ #endif
+ ]),
+       [ac_cv_c_excellent_fnmatch=yes],
+       [ac_cv_c_excellent_fnmatch=no])
+ ])
+ if test $ac_cv_c_excellent_fnmatch = yes; then
+       NO_FNMATCH_CASEFOLD=
+ else
+       NO_FNMATCH_CASEFOLD=YesPlease
+ fi
+ AC_SUBST(NO_FNMATCH_CASEFOLD)
+ #
  # Define NO_MEMMEM if you don't have memmem.
  GIT_CHECK_FUNC(memmem,
  [NO_MEMMEM=],
diff --cc dir.c
Simple merge
diff --cc fast-import.c
index 8263dbe841a6ac738c3a5a31006f3fdffcbc7e77,c3abe554cbd302f6fe982a4c655b3530a6a10563..534c68db6fe4d0c34c38e632bd2c442966cf8663
@@@ -1473,12 -1460,9 +1474,12 @@@ static int tree_content_set
        if (!slash1 && !S_ISDIR(mode) && subtree)
                die("Non-directories cannot have subtrees");
  
 +      if (!root->tree)
 +              load_tree(root);
 +      t = root->tree;
        for (i = 0; i < t->entry_count; i++) {
                e = t->entries[i];
-               if (e->name->str_len == n && !strncmp(p, e->name->str_dat, n)) {
+               if (e->name->str_len == n && !strncmp_icase(p, e->name->str_dat, n)) {
                        if (!slash1) {
                                if (!S_ISDIR(mode)
                                                && e->versions[1].mode == mode
@@@ -1542,20 -1526,9 +1543,20 @@@ static int tree_content_remove
        else
                n = strlen(p);
  
 +      if (!root->tree)
 +              load_tree(root);
 +      t = root->tree;
        for (i = 0; i < t->entry_count; i++) {
                e = t->entries[i];
-               if (e->name->str_len == n && !strncmp(p, e->name->str_dat, n)) {
+               if (e->name->str_len == n && !strncmp_icase(p, e->name->str_dat, n)) {
 +                      if (slash1 && !S_ISDIR(e->versions[1].mode))
 +                              /*
 +                               * If p names a file in some subdirectory, and a
 +                               * file or symlink matching the name of the
 +                               * parent directory of p exists, then p cannot
 +                               * exist and need not be deleted.
 +                               */
 +                              return 1;
                        if (!slash1 || !S_ISDIR(e->versions[1].mode))
                                goto del_entry;
                        if (!e->tree)
@@@ -1603,12 -1576,9 +1604,12 @@@ static int tree_content_get
        else
                n = strlen(p);
  
 +      if (!root->tree)
 +              load_tree(root);
 +      t = root->tree;
        for (i = 0; i < t->entry_count; i++) {
                e = t->entries[i];
-               if (e->name->str_len == n && !strncmp(p, e->name->str_dat, n)) {
+               if (e->name->str_len == n && !strncmp_icase(p, e->name->str_dat, n)) {
                        if (!slash1) {
                                memcpy(leaf, e, sizeof(*leaf));
                                if (e->tree && is_null_sha1(e->versions[1].sha1))
diff --cc read-cache.c
Simple merge