Merge branch 'bc/fopen'
authorJunio C Hamano <gitster@pobox.com>
Thu, 21 Feb 2008 00:13:19 +0000 (16:13 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 21 Feb 2008 00:13:19 +0000 (16:13 -0800)
* bc/fopen:
Add compat/fopen.c which returns NULL on attempt to open directory

1  2 
Makefile
git-compat-util.h
diff --combined Makefile
index 83c359acde102c653b197001b3272781f9fd2697,debfc236d25ed70714fe901642ceaa40497fa68b..d33a556ffed5c2cddb9577ea014d3c017082abb8
+++ b/Makefile
@@@ -3,6 -3,9 +3,9 @@@ all:
  
  # Define V=1 to have a more verbose compile.
  #
+ # Define FREAD_READS_DIRECTORIES if your are on a system which succeeds
+ # when attempting to read from an fopen'ed directory.
+ #
  # Define NO_OPENSSL environment variable if you do not have OpenSSL.
  # This also implies MOZILLA_SHA1.
  #
  # Define THREADED_DELTA_SEARCH if you have pthreads and wish to exploit
  # parallel delta searching when packing objects.
  #
 +# Define INTERNAL_QSORT to use Git's implementation of qsort(), which
 +# is a simplified version of the merge sort used in glibc. This is
 +# recommended if Git triggers O(n^2) behavior in your platform's qsort().
 +#
  
  GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
        @$(SHELL_PATH) ./GIT-VERSION-GEN
@@@ -235,7 -234,7 +238,7 @@@ SCRIPT_SH = 
        git-lost-found.sh git-quiltimport.sh git-submodule.sh \
        git-filter-branch.sh \
        git-stash.sh \
 -      git-help--browse.sh
 +      git-web--browse.sh
  
  SCRIPT_PERL = \
        git-add--interactive.perl \
@@@ -622,6 -621,10 +625,10 @@@ endi
  ifdef NO_C99_FORMAT
        BASIC_CFLAGS += -DNO_C99_FORMAT
  endif
+ ifdef FREAD_READS_DIRECTORIES
+       COMPAT_CFLAGS += -DFREAD_READS_DIRECTORIES
+       COMPAT_OBJS += compat/fopen.o
+ endif
  ifdef NO_SYMLINK_HEAD
        BASIC_CFLAGS += -DNO_SYMLINK_HEAD
  endif
@@@ -726,10 -729,6 +733,10 @@@ ifdef NO_MEMME
        COMPAT_CFLAGS += -DNO_MEMMEM
        COMPAT_OBJS += compat/memmem.o
  endif
 +ifdef INTERNAL_QSORT
 +      COMPAT_CFLAGS += -DINTERNAL_QSORT
 +      COMPAT_OBJS += compat/qsort.o
 +endif
  
  ifdef THREADED_DELTA_SEARCH
        BASIC_CFLAGS += -DTHREADED_DELTA_SEARCH
@@@ -827,7 -826,6 +834,7 @@@ git$X: git.o $(BUILTIN_OBJS) $(GITLIBS
  
  help.o: help.c common-cmds.h GIT-CFLAGS
        $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) \
 +              '-DGIT_HTML_PATH="$(htmldir_SQ)"' \
                '-DGIT_MAN_PATH="$(mandir_SQ)"' \
                '-DGIT_INFO_PATH="$(infodir_SQ)"' $<
  
@@@ -848,6 -846,7 +855,6 @@@ $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %
            -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
            -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
            -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
 -          -e 's|@@HTMLDIR@@|$(htmldir_SQ)|g' \
            $@.sh >$@+ && \
        chmod +x $@+ && \
        mv $@+ $@
diff --combined git-compat-util.h
index 05146047e0f33476df963e0e5aef30dd02a249fc,46d5e93c729ec8625eda0649071c887cbcbe8015..2a40703c851d7011723588dd7643dc034db49c31
@@@ -204,6 -204,11 +204,11 @@@ void *gitmemmem(const void *haystack, s
                  const void *needle, size_t needlelen);
  #endif
  
+ #ifdef FREAD_READS_DIRECTORIES
+ #define fopen(a,b) git_fopen(a,b)
+ extern FILE *git_fopen(const char*, const char*);
+ #endif
  #ifdef __GLIBC_PREREQ
  #if __GLIBC_PREREQ(2, 1)
  #define HAVE_STRCHRNUL
@@@ -426,10 -431,4 +431,10 @@@ static inline int strtol_i(char const *
        return 0;
  }
  
 +#ifdef INTERNAL_QSORT
 +void git_qsort(void *base, size_t nmemb, size_t size,
 +             int(*compar)(const void *, const void *));
 +#define qsort git_qsort
 +#endif
 +
  #endif