Merge branch 'nd/fileno-may-be-macro'
authorJunio C Hamano <gitster@pobox.com>
Thu, 14 Feb 2019 02:18:41 +0000 (18:18 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 14 Feb 2019 02:18:41 +0000 (18:18 -0800)
* nd/fileno-may-be-macro:
git-compat-util: work around fileno(fp) that is a macro

1  2 
Makefile
config.mak.uname
git-compat-util.h
diff --combined Makefile
index 0e13a5b4698a02e93c9f2c95e06b4193fe229567,08d9961425dbb88cbc7a2970231444588fd6379c..af7e809ced694635d1281dbcf3f0ab234ce3c137
+++ b/Makefile
@@@ -186,12 -186,6 +186,12 @@@ all:
  # in one call to the platform's SHA1_Update(). e.g. APPLE_COMMON_CRYPTO
  # wants 'SHA1_MAX_BLOCK_SIZE=1024L*1024L*1024L' defined.
  #
 +# Define BLK_SHA256 to use the built-in SHA-256 routines.
 +#
 +# Define GCRYPT_SHA256 to use the SHA-256 routines in libgcrypt.
 +#
 +# Define OPENSSL_SHA256 to use the SHA-256 routines in OpenSSL.
 +#
  # Define NEEDS_CRYPTO_WITH_SSL if you need -lcrypto when using -lssl (Darwin).
  #
  # Define NEEDS_SSL_WITH_CRYPTO if you need -lssl when using -lcrypto (Darwin).
  #
  # Define HAVE_GETDELIM if your system has the getdelim() function.
  #
+ # Define FILENO_IS_A_MACRO if fileno() is a macro, not a real function.
+ #
  # Define PAGER_ENV to a SP separated VAR=VAL pairs to define
  # default environment variables to be passed when a pager is spawned, e.g.
  #
@@@ -574,11 -570,7 +576,11 @@@ SPATCH = spatc
  
  export TCL_PATH TCLTK_PATH
  
 -SPARSE_FLAGS =
 +# user customisation variable for 'sparse' target
 +SPARSE_FLAGS ?=
 +# internal/platform customisation variable for 'sparse'
 +SP_EXTRA_FLAGS =
 +
  SPATCH_FLAGS = --all-includes --patch .
  
  
@@@ -638,6 -630,7 +640,6 @@@ SCRIPT_LIB += git-parse-remot
  SCRIPT_LIB += git-rebase--am
  SCRIPT_LIB += git-rebase--common
  SCRIPT_LIB += git-rebase--preserve-merges
 -SCRIPT_LIB += git-rebase--merge
  SCRIPT_LIB += git-sh-setup
  SCRIPT_LIB += git-sh-i18n
  
@@@ -693,7 -686,6 +695,7 @@@ SCRIPTS = $(SCRIPT_SH_INS) 
  
  ETAGS_TARGET = TAGS
  
 +FUZZ_OBJS += fuzz-commit-graph.o
  FUZZ_OBJS += fuzz-pack-headers.o
  FUZZ_OBJS += fuzz-pack-idx.o
  
@@@ -734,9 -726,7 +736,9 @@@ TEST_BUILTINS_OBJS += test-dump-split-i
  TEST_BUILTINS_OBJS += test-dump-untracked-cache.o
  TEST_BUILTINS_OBJS += test-example-decorate.o
  TEST_BUILTINS_OBJS += test-genrandom.o
 +TEST_BUILTINS_OBJS += test-hash.o
  TEST_BUILTINS_OBJS += test-hashmap.o
 +TEST_BUILTINS_OBJS += test-hash-speed.o
  TEST_BUILTINS_OBJS += test-index-version.o
  TEST_BUILTINS_OBJS += test-json-writer.o
  TEST_BUILTINS_OBJS += test-lazy-init-name-hash.o
@@@ -759,7 -749,6 +761,7 @@@ TEST_BUILTINS_OBJS += test-run-command.
  TEST_BUILTINS_OBJS += test-scrap-cache-tree.o
  TEST_BUILTINS_OBJS += test-sha1.o
  TEST_BUILTINS_OBJS += test-sha1-array.o
 +TEST_BUILTINS_OBJS += test-sha256.o
  TEST_BUILTINS_OBJS += test-sigchain.o
  TEST_BUILTINS_OBJS += test-strcmp-offset.o
  TEST_BUILTINS_OBJS += test-string-list.o
@@@ -767,7 -756,6 +769,7 @@@ TEST_BUILTINS_OBJS += test-submodule-co
  TEST_BUILTINS_OBJS += test-submodule-nested-repo-config.o
  TEST_BUILTINS_OBJS += test-subprocess.o
  TEST_BUILTINS_OBJS += test-urlmatch-normalization.o
 +TEST_BUILTINS_OBJS += test-xml-encode.o
  TEST_BUILTINS_OBJS += test-wildmatch.o
  TEST_BUILTINS_OBJS += test-windows-named-pipe.o
  TEST_BUILTINS_OBJS += test-write-cache.o
@@@ -1660,19 -1648,6 +1662,19 @@@ endi
  endif
  endif
  
 +ifdef OPENSSL_SHA256
 +      EXTLIBS += $(LIB_4_CRYPTO)
 +      BASIC_CFLAGS += -DSHA256_OPENSSL
 +else
 +ifdef GCRYPT_SHA256
 +      BASIC_CFLAGS += -DSHA256_GCRYPT
 +      EXTLIBS += -lgcrypt
 +else
 +      LIB_OBJS += sha256/block/sha256.o
 +      BASIC_CFLAGS += -DSHA256_BLK
 +endif
 +endif
 +
  ifdef SHA1_MAX_BLOCK_SIZE
        LIB_OBJS += compat/sha1-chunked.o
        BASIC_CFLAGS += -DSHA1_MAX_BLOCK_SIZE="$(SHA1_MAX_BLOCK_SIZE)"
@@@ -1800,6 -1775,11 +1802,11 @@@ ifdef HAVE_WPGMPT
        BASIC_CFLAGS += -DHAVE_WPGMPTR
  endif
  
+ ifdef FILENO_IS_A_MACRO
+       COMPAT_CFLAGS += -DFILENO_IS_A_MACRO
+       COMPAT_OBJS += compat/fileno.o
+ endif
  ifeq ($(TCLTK_PATH),)
  NO_TCLTK = NoThanks
  endif
@@@ -2374,10 -2354,10 +2381,10 @@@ gettext.sp gettext.s gettext.o: GIT-PRE
  gettext.sp gettext.s gettext.o: EXTRA_CPPFLAGS = \
        -DGIT_LOCALE_PATH='"$(localedir_relative_SQ)"'
  
 -http-push.sp http.sp http-walker.sp remote-curl.sp imap-send.sp: SPARSE_FLAGS += \
 +http-push.sp http.sp http-walker.sp remote-curl.sp imap-send.sp: SP_EXTRA_FLAGS += \
        -DCURL_DISABLE_TYPECHECK
  
 -pack-revindex.sp: SPARSE_FLAGS += -Wno-memcpy-max-count
 +pack-revindex.sp: SP_EXTRA_FLAGS += -Wno-memcpy-max-count
  
  ifdef NO_EXPAT
  http-walker.sp http-walker.s http-walker.o: EXTRA_CPPFLAGS = -DNO_EXPAT
@@@ -2391,7 -2371,7 +2398,7 @@@ endi
  ifdef USE_NED_ALLOCATOR
  compat/nedmalloc/nedmalloc.sp compat/nedmalloc/nedmalloc.o: EXTRA_CPPFLAGS = \
        -DNDEBUG -DREPLACE_SYSTEM_ALLOCATOR
 -compat/nedmalloc/nedmalloc.sp: SPARSE_FLAGS += -Wno-non-pointer-null
 +compat/nedmalloc/nedmalloc.sp: SP_EXTRA_FLAGS += -Wno-non-pointer-null
  endif
  
  git-%$X: %.o GIT-LDFLAGS $(GITLIBS)
@@@ -2715,7 -2695,7 +2722,7 @@@ SP_OBJ = $(patsubst %.o,%.sp,$(C_OBJ)
  
  $(SP_OBJ): %.sp: %.c GIT-CFLAGS FORCE
        $(QUIET_SP)cgcc -no-compile $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) \
 -              $(SPARSE_FLAGS) $<
 +              $(SPARSE_FLAGS) $(SP_EXTRA_FLAGS) $<
  
  .PHONY: sparse $(SP_OBJ)
  sparse: $(SP_OBJ)
@@@ -2953,16 -2933,6 +2960,16 @@@ rpm:
        @false
  .PHONY: rpm
  
 +artifacts-tar:: $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) $(OTHER_PROGRAMS) \
 +              GIT-BUILD-OPTIONS $(TEST_PROGRAMS) $(test_bindir_programs) \
 +              $(NO_INSTALL) $(MOFILES)
 +      $(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1) \
 +              SHELL_PATH='$(SHELL_PATH_SQ)' PERL_PATH='$(PERL_PATH_SQ)'
 +      test -n "$(ARTIFACTS_DIRECTORY)"
 +      mkdir -p "$(ARTIFACTS_DIRECTORY)"
 +      $(TAR) czf "$(ARTIFACTS_DIRECTORY)/artifacts.tar.gz" $^ templates/blt/
 +.PHONY: artifacts-tar
 +
  htmldocs = git-htmldocs-$(GIT_VERSION)
  manpages = git-manpages-$(GIT_VERSION)
  .PHONY: dist-doc distclean
@@@ -3114,11 -3084,6 +3121,11 @@@ coverage-test: coverage-clean-results c
        $(MAKE) CFLAGS="$(COVERAGE_CFLAGS)" LDFLAGS="$(COVERAGE_LDFLAGS)" \
                DEFAULT_TEST_TARGET=test -j1 test
  
 +coverage-prove: coverage-clean-results coverage-compile
 +      $(MAKE) CFLAGS="$(COVERAGE_CFLAGS)" LDFLAGS="$(COVERAGE_LDFLAGS)" \
 +              DEFAULT_TEST_TARGET=prove GIT_PROVE_OPTS="$(GIT_PROVE_OPTS) -j1" \
 +              -j1 test
 +
  coverage-report:
        $(QUIET_GCOV)for dir in $(object_dirs); do \
                $(GCOV) $(GCOVFLAGS) --object-directory=$$dir $$dir*.c || exit; \
@@@ -3145,7 -3110,7 +3152,7 @@@ cover_db_html: cover_d
  # An example command to build against libFuzzer from LLVM 4.0.0:
  #
  # make CC=clang CXX=clang++ \
 -#      FUZZ_CXXFLAGS="-fsanitize-coverage=trace-pc-guard -fsanitize=address" \
 +#      CFLAGS="-fsanitize-coverage=trace-pc-guard -fsanitize=address" \
  #      LIB_FUZZING_ENGINE=/usr/lib/llvm-4.0/lib/libFuzzer.a \
  #      fuzz-all
  #
diff --combined config.mak.uname
index 281c547e2f6ef617029821a617d518ea5e133915,23eac5ac9dca643220ac345ecd99835928e86e6b..bd55e828cabd2a4b17ebf8a8735027c5c8d950f7
@@@ -187,7 -187,7 +187,7 @@@ ifeq ($(uname_O),Cygwin
        UNRELIABLE_FSTAT = UnfortunatelyYes
        OBJECT_CREATION_USES_RENAMES = UnfortunatelyNeedsTo
        MMAP_PREVENTS_DELETE = UnfortunatelyYes
 -      COMPAT_OBJS += compat/cygwin.o
 +      COMPAT_OBJS += compat/win32/path-utils.o
        FREAD_READS_DIRECTORIES = UnfortunatelyYes
  endif
  ifeq ($(uname_S),FreeBSD)
        HAVE_BSD_KERN_PROC_SYSCTL = YesPlease
        PAGER_ENV = LESS=FRX LV=-c MORE=FRX
        FREAD_READS_DIRECTORIES = UnfortunatelyYes
+       FILENO_IS_A_MACRO = UnfortunatelyYes
  endif
  ifeq ($(uname_S),OpenBSD)
        NO_STRCASESTR = YesPlease
        HAVE_BSD_SYSCTL = YesPlease
        HAVE_BSD_KERN_PROC_SYSCTL = YesPlease
        PROCFS_EXECUTABLE_PATH = /proc/curproc/file
 +      FREAD_READS_DIRECTORIES = UnfortunatelyYes
+       FILENO_IS_A_MACRO = UnfortunatelyYes
  endif
  ifeq ($(uname_S),MirBSD)
        NO_STRCASESTR = YesPlease
@@@ -442,43 -443,26 +444,43 @@@ ifeq ($(uname_S),NONSTOP_KERNEL
        # INLINE='' would just replace one set of warnings with another and
        # still not compile in c89 mode, due to non-const array initializations.
        CC = cc -c99
 +      # Build down-rev compatible objects that don't use our new getopt_long.
 +      ifeq ($(uname_R).$(uname_V),J06.21)
 +              CC += -WRVU=J06.20
 +      endif
 +      ifeq ($(uname_R).$(uname_V),L17.02)
 +              CC += -WRVU=L16.05
 +      endif
        # Disable all optimization, seems to result in bad code, with -O or -O2
        # or even -O1 (default), /usr/local/libexec/git-core/git-pack-objects
        # abends on "git push". Needs more investigation.
 -      CFLAGS = -g -O0
 +      CFLAGS = -g -O0 -Winline
        # We'd want it to be here.
        prefix = /usr/local
 -      # Our's are in ${prefix}/bin (perl might also be in /usr/bin/perl).
 -      PERL_PATH = ${prefix}/bin/perl
 -      PYTHON_PATH = ${prefix}/bin/python
 -
 +      # perl and python must be in /usr/bin on NonStop - supplied by HPE
 +      # with operating system in that managed directory.
 +      PERL_PATH = /usr/bin/perl
 +      PYTHON_PATH = /usr/bin/python
 +      # The current /usr/coreutils/rm at lowest support level does not work
 +      # with the git test structure. Long paths as in
 +      # 'trash directory...' cause rm to terminate prematurely without fully
 +      # removing the directory at OS releases J06.21 and L17.02.
 +      # Default to the older rm until those two releases are deprecated.
 +      RM = /bin/rm -f
        # As detected by './configure'.
        # Missdetected, hence commented out, see below.
        #NO_CURL = YesPlease
        # Added manually, see above.
 +      NEEDS_SSL_WITH_CURL = YesPlease
 +      NEEDS_CRYPTO_WITH_SSL = YesPlease
 +      HAVE_DEV_TTY = YesPlease
        HAVE_LIBCHARSET_H = YesPlease
        HAVE_STRINGS_H = YesPlease
        NEEDS_LIBICONV = YesPlease
        NEEDS_LIBINTL_BEFORE_LIBICONV = YesPlease
        NO_SYS_SELECT_H = UnfortunatelyYes
        NO_D_TYPE_IN_DIRENT = YesPlease
 +      NO_GETTEXT = YesPlease
        NO_HSTRERROR = YesPlease
        NO_STRCASESTR = YesPlease
        NO_MEMMEM = YesPlease
        NO_MKDTEMP = YesPlease
        # Currently libiconv-1.9.1.
        OLD_ICONV = UnfortunatelyYes
 -      NO_REGEX = YesPlease
 +      NO_REGEX = NeedsStartEnd
        NO_PTHREADS = UnfortunatelyYes
 +      FREAD_READS_DIRECTORIES = UnfortunatelyYes
  
        # Not detected (nor checked for) by './configure'.
        # We don't have SA_RESTART on NonStop, unfortunalety.
@@@ -546,7 -529,6 +548,7 @@@ ifneq (,$(findstring MINGW,$(uname_S))
        COMPAT_CFLAGS += -DNOGDI -Icompat -Icompat/win32
        COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
        COMPAT_OBJS += compat/mingw.o compat/winansi.o \
 +              compat/win32/path-utils.o \
                compat/win32/pthread.o compat/win32/syslog.o \
                compat/win32/dirent.o
        BASIC_CFLAGS += -DWIN32 -DPROTECT_NTFS_DEFAULT=1
        RC = windres -O coff
        NATIVE_CRLF = YesPlease
        X = .exe
 -      SPARSE_FLAGS = -Wno-one-bit-signed-bitfield
  ifneq (,$(wildcard ../THIS_IS_MSYSGIT))
        htmldir = doc/git/html/
        prefix =
diff --combined git-compat-util.h
index 29a19902aaa00b90176e253c90c2384fca65857c,7899f42f5ebbd77f34aed85f3f01245360328daa..6573808ebd991b52eca7cc644af4c9611b9c3747
  #endif
  
  #if defined(__CYGWIN__)
 -#include "compat/cygwin.h"
 +#include "compat/win32/path-utils.h"
  #endif
  #if defined(__MINGW32__)
  /* pull in Windows compatibility stuff */
 +#include "compat/win32/path-utils.h"
  #include "compat/mingw.h"
  #elif defined(_MSC_VER)
  #include "compat/msvc.h"
@@@ -398,19 -397,6 +398,19 @@@ static inline char *git_find_last_dir_s
  #define query_user_email() NULL
  #endif
  
 +#ifdef __TANDEM
 +#include <floss.h(floss_execl,floss_execlp,floss_execv,floss_execvp)>
 +#include <floss.h(floss_getpwuid)>
 +#ifndef NSIG
 +/*
 + * NonStop NSE and NSX do not provide NSIG. SIGGUARDIAN(99) is the highest
 + * known, by detective work using kill -l as a list is all signals
 + * instead of signal.h where it should be.
 + */
 +# define NSIG 100
 +#endif
 +#endif
 +
  #if defined(__HP_cc) && (__HP_cc >= 61000)
  #define NORETURN __attribute__((noreturn))
  #define NORETURN_PTR
@@@ -735,7 -721,7 +735,7 @@@ extern const char *githstrerror(int her
  #ifdef NO_MEMMEM
  #define memmem gitmemmem
  void *gitmemmem(const void *haystack, size_t haystacklen,
 -                const void *needle, size_t needlelen);
 +              const void *needle, size_t needlelen);
  #endif
  
  #ifdef OVERRIDE_STRDUP
@@@ -1234,6 -1220,14 +1234,14 @@@ struct tm *git_gmtime_r(const time_t *
  #define getc_unlocked(fh) getc(fh)
  #endif
  
+ #ifdef FILENO_IS_A_MACRO
+ int git_fileno(FILE *stream);
+ # ifndef COMPAT_CODE
+ #  undef fileno
+ #  define fileno(p) git_fileno(p)
+ # endif
+ #endif
  /*
   * Our code often opens a path to an optional file, to work on its
   * contents when we can successfully open it.  We can ignore a failure