1. 07 10月, 2011 1 次提交
    • B
      cleanup: use internal memory allocation wrapper functions everywhere · 040a6551
      Brandon Casey 提交于
      The "x"-prefixed versions of strdup, malloc, etc. will check whether the
      allocation was successful and terminate the process otherwise.
      
      A few uses of malloc were left alone since they already implemented a
      graceful path of failure or were in a quasi external library like xdiff.
      
      Additionally, the call to malloc in compat/win32/syslog.c was not modified
      since the syslog() implemented there is a die handler and a call to the
      x-wrappers within a die handler could result in recursion should memory
      allocation fail.  This will have to be addressed separately.
      Signed-off-by: NBrandon Casey <drafnel@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      040a6551
  2. 07 6月, 2011 2 次提交
    • J
      Windows: teach getenv to do a case-sensitive search · df599e96
      Johannes Sixt 提交于
      getenv() on Windows looks up environment variables in a case-insensitive
      manner. Even though all documentations claim that the environment is
      case-insensitive, it is possible for applications to pass an environment
      to child processes that has variables that differ only in case. Bash on
      Windows does this, for example, and sh-i18n--envsubst depends on this
      behavior.
      
      With this patch environment variables are first looked up in a
      case-sensitive manner; only if this finds nothing, the system's getenv() is
      used as a fallback.
      Signed-off-by: NJohannes Sixt <j6t@kdbg.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      df599e96
    • J
      mingw.c: move definition of mingw_getenv down · 06bc4b79
      Johannes Sixt 提交于
      We want to use static lookup_env() in a subsequent change.
      
      At first sight, this change looks innocent. But it is not due to the
      #undef getenv. There is one caller of getenv between the old location and
      the new location whose behavior could change. But as can be seen from the
      defintion of mingw_getenv, the behavior for this caller does not change
      substantially.
      
      To ensure consistent behavior in the future, change all getenv callers
      in mingw.c to use mingw_getenv.
      
      With this patch, this is not a big deal, yet, but with the subsequent
      change, where we teach getenv to do a case-sensitive lookup, the behavior
      of all call sites is changed.
      Signed-off-by: NJohannes Sixt <j6t@kdbg.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      06bc4b79
  3. 19 5月, 2011 1 次提交
  4. 14 4月, 2011 1 次提交
  5. 08 2月, 2011 5 次提交
  6. 24 11月, 2010 3 次提交
  7. 05 11月, 2010 6 次提交
  8. 04 10月, 2010 2 次提交
  9. 02 10月, 2010 2 次提交
  10. 23 8月, 2010 1 次提交
  11. 13 7月, 2010 1 次提交
  12. 21 5月, 2010 1 次提交
  13. 12 4月, 2010 1 次提交
  14. 31 3月, 2010 1 次提交
  15. 26 2月, 2010 1 次提交
  16. 17 1月, 2010 5 次提交
    • J
      Do not use date.c:tm_to_time_t() from compat/mingw.c · a6d15bc3
      Johannes Sixt 提交于
      To implement gettimeofday(), a broken-down UTC time was requested from the
      system using GetSystemTime(), then tm_to_time_t() was used to convert it
      to a time_t because it does not look at the current timezone, which
      mktime() would do.
      
      Use GetSystemTimeAsFileTime() and a different conversion path to avoid this
      back-reference from the compatibility layer to the generic code.
      Signed-off-by: NJohannes Sixt <j6t@kdbg.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a6d15bc3
    • A
      MSVC: Windows-native implementation for subset of Pthreads API · 44626dc7
      Andrzej K. Haczewski 提交于
      This patch implements native to Windows subset of pthreads API used by Git.
      It allows to remove Pthreads for Win32 dependency for MSVC, msysgit and
      Cygwin.
      
      [J6t: If the MinGW build was built as part of the msysgit build
      environment, then threading was already enabled because the
      pthreads-win32 package is available in msysgit. With this patch, we can now
      enable threaded code unconditionally.]
      Signed-off-by: NAndrzej K. Haczewski <ahaczewski@gmail.com>
      Signed-off-by: NJohannes Sixt <j6t@kdbg.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      44626dc7
    • J
      Windows: avoid the "dup dance" when spawning a child process · 75301f90
      Johannes Sixt 提交于
      When stdin, stdout, or stderr must be redirected for a child process that
      on Windows is spawned using one of the spawn() functions of Microsoft's
      C runtime, then there is no choice other than to
      
      1. make a backup copy of fd 0,1,2 with dup
      2. dup2 the redirection source fd into 0,1,2
      3. spawn
      4. dup2 the backup back into 0,1,2
      5. close the backup copy and the redirection source
      
      We used this idiom as well -- but we are not using the spawn() functions
      anymore!
      
      Instead, we have our own implementation. We had hardcoded that stdin,
      stdout, and stderr of the child process were inherited from the parent's
      fds 0, 1, and 2. But we can actually specify any fd.
      
      With this patch, the fds to inherit are passed from start_command()'s
      WIN32 section to our spawn implementation. This way, we can avoid the
      backup copies of the fds.
      
      The backup copies were a bug waiting to surface: The OS handles underlying
      the dup()ed fds were inherited by the child process (but were not
      associated with a file descriptor in the child). Consequently, the file or
      pipe represented by the OS handle remained open even after the backup copy
      was closed in the parent process until the child exited.
      
      Since our implementation of pipe() creates non-inheritable OS handles, we
      still dup() file descriptors in start_command() because dup() happens to
      create inheritable duplicates. (A nice side effect is that the fd cleanup
      in start_command is the same for Windows and Unix and remains unchanged.)
      Signed-off-by: NJohannes Sixt <j6t@kdbg.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      75301f90
    • J
      Windows: simplify the pipe(2) implementation · 3e34d665
      Johannes Sixt 提交于
      Our implementation of pipe() must create non-inheritable handles for the
      reason that when a child process is started, there is no opportunity to
      close the unneeded pipe ends in the child (on POSIX this is done between
      fork() and exec()).
      
      Previously, we used the _pipe() function provided by Microsoft's C runtime
      (which creates inheritable handles) and then turned the handles into
      non-inheritable handles using the DuplicateHandle() API.
      
      Simplify the procedure by using the CreatePipe() API, which can create
      non-inheritable handles right from the beginning.
      Signed-off-by: NJohannes Sixt <j6t@kdbg.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      3e34d665
    • J
      Windows: boost startup by avoiding a static dependency on shell32.dll · 928500e0
      Johannes Sixt 提交于
      This DLL is only needed to invoke the browser in a "git help" call. By
      looking up the only function that we need at runtime, we can avoid the
      startup costs of this DLL.
      
      DLL usage can be profiled with Microsoft's Dependency Walker. For example,
      a call to "git diff-files" loaded
      
      before:  19 DLLs
      after:    9 DLLs
      
      As a result, the runtime of 'make -j2 test' went down from 16:00min
      to 12:40min on one of my boxes.
      Signed-off-by: NJohannes Sixt <j6t@kdbg.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      928500e0
  17. 24 11月, 2009 2 次提交
  18. 09 11月, 2009 1 次提交
  19. 19 9月, 2009 3 次提交