Merge branch 'sp/msysgit'
authorJunio C Hamano <gitster@pobox.com>
Sat, 13 Jun 2009 19:50:42 +0000 (12:50 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sat, 13 Jun 2009 19:50:42 +0000 (12:50 -0700)
* sp/msysgit:
compat/ has subdirectories: do not omit them in 'make clean'
Fix typo in nedmalloc warning fix
MinGW: Teach Makefile to detect msysgit and apply specific settings
Fix warnings in nedmalloc when compiling with GCC 4.4.0
Add custom memory allocator to MinGW and MacOS builds
MinGW readdir reimplementation to support d_type
connect.c: Support PuTTY plink and TortoisePlink as SSH on Windows
git: browsing paths with spaces when using the start command
MinGW: fix warning about implicit declaration of _getch()
test-chmtime: work around Windows limitation
Work around a regression in Windows 7, causing erase_in_line() to crash sometimes
Quiet make: do not leave Windows behind
MinGW: GCC >= 4 does not need SNPRINTF_SIZE_CORR anymore

Conflicts:
Makefile

1  2 
Makefile
connect.c
diff --combined Makefile
index 735ab079c07b73964b37dfc6c5ac4ee6d1ebcf57,867438de95d7a685f9babc79c3edb76fea110715..41ab8e9e0db59647b2e872757ec05e86f615ea1c
+++ b/Makefile
@@@ -3,11 -3,6 +3,11 @@@ all:
  
  # Define V=1 to have a more verbose compile.
  #
 +# Define SHELL_PATH to a POSIX shell if your /bin/sh is broken.
 +#
 +# Define SANE_TOOL_PATH to a colon-separated list of paths to prepend
 +# to PATH if your tools in /usr/bin are broken.
 +#
  # Define SNPRINTF_RETURNS_BOGUS if your are on a system which snprintf()
  # or vsnprintf() return -1 instead of number of characters which would
  # have been written to the final string if enough space had been available.
  #
  # Define NO_MKDTEMP if you don't have mkdtemp in the C library.
  #
 +# Define NO_MKSTEMPS if you don't have mkstemps in the C library.
 +#
 +# Define NO_LIBGEN_H if you don't have libgen.h.
 +#
  # Define NO_SYS_SELECT_H if you don't have sys/select.h.
  #
  # Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link.
  # Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
  # Patrick Mauritz).
  #
 +# Define NEEDS_RESOLV if linking with -lnsl and/or -lsocket is not enough.
 +# Notably on Solaris hstrerror resides in libresolv and on Solaris 7
 +# inet_ntop and inet_pton additionally reside there.
 +#
  # Define NO_MMAP if you want to avoid mmap.
  #
  # Define NO_PTHREADS if you do not have or do not want to use Pthreads.
  #
  # Define NO_CROSS_DIRECTORY_HARDLINKS if you plan to distribute the installed
  # programs as a tar, where bin/ and libexec/ might be on different file systems.
+ #
+ # Define USE_NED_ALLOCATOR if you want to replace the platforms default
+ # memory allocators with the nedmalloc allocator written by Niall Douglas.
  
  GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
        @$(SHELL_PATH) ./GIT-VERSION-GEN
@@@ -649,12 -639,10 +652,12 @@@ EXTLIBS 
  
  ifeq ($(uname_S),Linux)
        NO_STRLCPY = YesPlease
 +      NO_MKSTEMPS = YesPlease
        THREADED_DELTA_SEARCH = YesPlease
  endif
  ifeq ($(uname_S),GNU/kFreeBSD)
        NO_STRLCPY = YesPlease
 +      NO_MKSTEMPS = YesPlease
        THREADED_DELTA_SEARCH = YesPlease
  endif
  ifeq ($(uname_S),UnixWare)
        SHELL_PATH = /usr/local/bin/bash
        NO_IPV6 = YesPlease
        NO_HSTRERROR = YesPlease
 +      NO_MKSTEMPS = YesPlease
        BASIC_CFLAGS += -Kthread
        BASIC_CFLAGS += -I/usr/local/include
        BASIC_LDFLAGS += -L/usr/local/lib
@@@ -690,7 -677,6 +693,7 @@@ ifeq ($(uname_S),SCO_SV
        SHELL_PATH = /usr/bin/bash
        NO_IPV6 = YesPlease
        NO_HSTRERROR = YesPlease
 +      NO_MKSTEMPS = YesPlease
        BASIC_CFLAGS += -I/usr/local/include
        BASIC_LDFLAGS += -L/usr/local/lib
        NO_STRCASESTR = YesPlease
@@@ -715,20 -701,12 +718,20 @@@ ifeq ($(uname_S),SunOS
        NEEDS_SOCKET = YesPlease
        NEEDS_NSL = YesPlease
        SHELL_PATH = /bin/bash
 +      SANE_TOOL_PATH = /usr/xpg6/bin:/usr/xpg4/bin
        NO_STRCASESTR = YesPlease
        NO_MEMMEM = YesPlease
 -      NO_HSTRERROR = YesPlease
        NO_MKDTEMP = YesPlease
 -      ifneq ($(uname_R),5.11)
 -              OLD_ICONV = UnfortunatelyYes
 +      NO_MKSTEMPS = YesPlease
 +      ifeq ($(uname_R),5.7)
 +              NEEDS_RESOLV = YesPlease
 +              NO_IPV6 = YesPlease
 +              NO_SOCKADDR_STORAGE = YesPlease
 +              NO_UNSETENV = YesPlease
 +              NO_SETENV = YesPlease
 +              NO_STRLCPY = YesPlease
 +              NO_C99_FORMAT = YesPlease
 +              NO_STRTOUMAX = YesPlease
        endif
        ifeq ($(uname_R),5.8)
                NO_UNSETENV = YesPlease
                NO_C99_FORMAT = YesPlease
                NO_STRTOUMAX = YesPlease
        endif
 -      INSTALL = ginstall
 +      ifdef NO_IPV6
 +              NEEDS_RESOLV = YesPlease
 +      endif
 +      INSTALL = /usr/ucb/install
        TAR = gtar
 -      BASIC_CFLAGS += -D__EXTENSIONS__
 +      BASIC_CFLAGS += -D__EXTENSIONS__ -D__sun__
  endif
  ifeq ($(uname_O),Cygwin)
        NO_D_TYPE_IN_DIRENT = YesPlease
        NO_D_INO_IN_DIRENT = YesPlease
        NO_STRCASESTR = YesPlease
        NO_MEMMEM = YesPlease
 +      NO_MKSTEMPS = YesPlease
        NO_SYMLINK_HEAD = YesPlease
        NEEDS_LIBICONV = YesPlease
        NO_FAST_WORKING_DIRECTORY = UnfortunatelyYes
@@@ -798,13 -772,11 +801,13 @@@ ifeq ($(uname_S),NetBSD
        BASIC_LDFLAGS += -L/usr/pkg/lib $(CC_LD_DYNPATH)/usr/pkg/lib
        THREADED_DELTA_SEARCH = YesPlease
        USE_ST_TIMESPEC = YesPlease
 +      NO_MKSTEMPS = YesPlease
  endif
  ifeq ($(uname_S),AIX)
        NO_STRCASESTR=YesPlease
        NO_MEMMEM = YesPlease
        NO_MKDTEMP = YesPlease
 +      NO_MKSTEMPS = YesPlease
        NO_STRLCPY = YesPlease
        NO_NSEC = YesPlease
        FREAD_READS_DIRECTORIES = UnfortunatelyYes
@@@ -820,14 -792,12 +823,14 @@@ endi
  ifeq ($(uname_S),GNU)
        # GNU/Hurd
        NO_STRLCPY=YesPlease
 +      NO_MKSTEMPS = YesPlease
  endif
  ifeq ($(uname_S),IRIX64)
        NO_IPV6=YesPlease
        NO_SETENV=YesPlease
        NO_STRCASESTR=YesPlease
        NO_MEMMEM = YesPlease
 +      NO_MKSTEMPS = YesPlease
        NO_STRLCPY = YesPlease
        NO_SOCKADDR_STORAGE=YesPlease
        SHELL_PATH=/usr/gnu/bin/bash
@@@ -840,7 -810,6 +843,7 @@@ ifeq ($(uname_S),HP-UX
        NO_SETENV=YesPlease
        NO_STRCASESTR=YesPlease
        NO_MEMMEM = YesPlease
 +      NO_MKSTEMPS = YesPlease
        NO_STRLCPY = YesPlease
        NO_MKDTEMP = YesPlease
        NO_UNSETENV = YesPlease
@@@ -856,8 -825,6 +859,7 @@@ ifneq (,$(findstring MINGW,$(uname_S))
        pathsep = ;
        NO_PREAD = YesPlease
        NO_OPENSSL = YesPlease
-       NO_CURL = YesPlease
 +      NO_LIBGEN_H = YesPlease
        NO_SYMLINK_HEAD = YesPlease
        NO_IPV6 = YesPlease
        NO_SETENV = YesPlease
        NO_STRCASESTR = YesPlease
        NO_STRLCPY = YesPlease
        NO_MEMMEM = YesPlease
-       NO_PTHREADS = YesPlease
        NEEDS_LIBICONV = YesPlease
        OLD_ICONV = YesPlease
        NO_C99_FORMAT = YesPlease
        NO_STRTOUMAX = YesPlease
        NO_MKDTEMP = YesPlease
 +      NO_MKSTEMPS = YesPlease
        SNPRINTF_RETURNS_BOGUS = YesPlease
        NO_SVN_TESTS = YesPlease
        NO_PERL_MAKEMAKER = YesPlease
        NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
        NO_NSEC = YesPlease
        USE_WIN32_MMAP = YesPlease
+       USE_NED_ALLOCATOR = YesPlease
        UNRELIABLE_FSTAT = UnfortunatelyYes
        OBJECT_CREATION_USES_RENAMES = UnfortunatelyNeedsTo
        COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -DNOGDI -Icompat -Icompat/regex -Icompat/fnmatch
-       COMPAT_CFLAGS += -DSNPRINTF_SIZE_CORR=1
        COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
        COMPAT_OBJS += compat/mingw.o compat/fnmatch/fnmatch.o compat/regex/regex.o compat/winansi.o
        EXTLIBS += -lws2_32
        X = .exe
+ ifneq (,$(wildcard ../THIS_IS_MSYSGIT))
+       htmldir=doc/git/html/
+       prefix =
+       INSTALL = /bin/install
+       EXTLIBS += /mingw/lib/libz.a
+       NO_R_TO_GCC_LINKER = YesPlease
+       INTERNAL_QSORT = YesPlease
+       THREADED_DELTA_SEARCH = YesPlease
+ else
+       NO_CURL = YesPlease
+       NO_PTHREADS = YesPlease
+ endif
  endif
  ifneq (,$(findstring arm,$(uname_M)))
        ARM_SHA1 = YesPlease
 +      NO_MKSTEMPS = YesPlease
  endif
  
  -include config.mak.autogen
  -include config.mak
  
 +ifdef SANE_TOOL_PATH
 +SANE_TOOL_PATH_SQ = $(subst ','\'',$(SANE_TOOL_PATH))
 +BROKEN_PATH_FIX = 's|^\# @@BROKEN_PATH_FIX@@$$|git_broken_path_fix $(SANE_TOOL_PATH_SQ)|'
 +PATH := $(SANE_TOOL_PATH):${PATH}
 +else
 +BROKEN_PATH_FIX = '/^\# @@BROKEN_PATH_FIX@@$$/d'
 +endif
 +
  ifeq ($(uname_S),Darwin)
        ifndef NO_FINK
                ifeq ($(shell test -d /sw/lib && echo y),y)
@@@ -931,11 -899,6 +944,11 @@@ ifndef CC_LD_DYNPAT
        endif
  endif
  
 +ifdef NO_LIBGEN_H
 +      COMPAT_CFLAGS += -DNO_LIBGEN_H
 +      COMPAT_OBJS += compat/basename.o
 +endif
 +
  ifdef NO_CURL
        BASIC_CFLAGS += -DNO_CURL
  else
@@@ -1008,9 -971,6 +1021,9 @@@ endi
  ifdef NEEDS_NSL
        EXTLIBS += -lnsl
  endif
 +ifdef NEEDS_RESOLV
 +      EXTLIBS += -lresolv
 +endif
  ifdef NO_D_TYPE_IN_DIRENT
        BASIC_CFLAGS += -DNO_D_TYPE_IN_DIRENT
  endif
@@@ -1066,10 -1026,6 +1079,10 @@@ ifdef NO_MKDTEM
        COMPAT_CFLAGS += -DNO_MKDTEMP
        COMPAT_OBJS += compat/mkdtemp.o
  endif
 +ifdef NO_MKSTEMPS
 +      COMPAT_CFLAGS += -DNO_MKSTEMPS
 +      COMPAT_OBJS += compat/mkstemps.o
 +endif
  ifdef NO_UNSETENV
        COMPAT_CFLAGS += -DNO_UNSETENV
        COMPAT_OBJS += compat/unsetenv.o
@@@ -1188,6 -1144,11 +1201,11 @@@ ifdef UNRELIABLE_FSTA
        BASIC_CFLAGS += -DUNRELIABLE_FSTAT
  endif
  
+ ifdef USE_NED_ALLOCATOR
+        COMPAT_CFLAGS += -DUSE_NED_ALLOCATOR -DOVERRIDE_STRDUP -DNDEBUG -DREPLACE_SYSTEM_ALLOCATOR -Icompat/nedmalloc
+        COMPAT_OBJS += compat/nedmalloc/nedmalloc.o
+ endif
  ifeq ($(TCLTK_PATH),)
  NO_TCLTK=NoThanks
  endif
@@@ -1262,7 -1223,7 +1280,7 @@@ SHELL = $(SHELL_PATH
  
  all:: shell_compatibility_test $(ALL_PROGRAMS) $(BUILT_INS) $(OTHER_PROGRAMS) GIT-BUILD-OPTIONS
  ifneq (,$X)
-       $(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), test '$p' -ef '$p$X' || $(RM) '$p';)
+       $(QUIET_BUILT_IN)$(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), test '$p' -ef '$p$X' || $(RM) '$p';)
  endif
  
  all::
@@@ -1315,7 -1276,6 +1333,7 @@@ $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %
            -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
            -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
            -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
 +          -e $(BROKEN_PATH_FIX) \
            $@.sh >$@+ && \
        chmod +x $@+ && \
        mv $@+ $@
@@@ -1555,8 -1515,6 +1573,8 @@@ test-delta$X: diff-delta.o patch-delta.
  
  test-parse-options$X: parse-options.o
  
 +test-parse-options.o: parse-options.h
 +
  .PRECIOUS: $(patsubst test-%$X,test-%.o,$(TEST_PROGRAMS))
  
  test-%$X: test-%.o $(GITLIBS)
@@@ -1704,7 -1662,7 +1722,7 @@@ distclean: clea
        $(RM) configure
  
  clean:
-       $(RM) *.o mozilla-sha1/*.o arm/*.o ppc/*.o compat/*.o xdiff/*.o \
+       $(RM) *.o mozilla-sha1/*.o arm/*.o ppc/*.o compat/*.o compat/*/*.o xdiff/*.o \
                $(LIB_FILE) $(XDIFF_LIB)
        $(RM) $(ALL_PROGRAMS) $(BUILT_INS) git$X
        $(RM) $(TEST_PROGRAMS)
diff --combined connect.c
index 958c831e430340435c31b640bd757d56b7cb8b71,692d47657899b8903042c06443d4ecc3a749bba0..0ce941ef444277957efdd8a359a568775e2b17a4
+++ b/connect.c
@@@ -579,10 -579,7 +579,10 @@@ struct child_process *git_connect(int f
                        git_tcp_connect(fd, host, flags);
                /*
                 * Separate original protocol components prog and path
 -               * from extended components with a NUL byte.
 +               * from extended host header with a NUL byte.
 +               *
 +               * Note: Do not add any other headers here!  Doing so
 +               * will cause older git-daemon servers to crash.
                 */
                packet_write(fd[1],
                             "%s %s%chost=%s%c",
                die("command line too long");
  
        conn->in = conn->out = -1;
-       conn->argv = arg = xcalloc(6, sizeof(*arg));
+       conn->argv = arg = xcalloc(7, sizeof(*arg));
        if (protocol == PROTO_SSH) {
                const char *ssh = getenv("GIT_SSH");
+               int putty = ssh && strcasestr(ssh, "plink");
                if (!ssh) ssh = "ssh";
  
                *arg++ = ssh;
+               if (putty && !strcasestr(ssh, "tortoiseplink"))
+                       *arg++ = "-batch";
                if (port) {
-                       *arg++ = "-p";
+                       /* P is for PuTTY, p is for OpenSSH */
+                       *arg++ = putty ? "-P" : "-p";
                        *arg++ = port;
                }
                *arg++ = host;