Merge branch 'jh/msvc'
authorJunio C Hamano <gitster@pobox.com>
Tue, 9 Jul 2019 22:25:45 +0000 (15:25 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 9 Jul 2019 22:25:45 +0000 (15:25 -0700)
Support to build with MSVC has been updated.

* jh/msvc:
msvc: ignore .dll and incremental compile output
msvc: avoid debug assertion windows in Debug Mode
msvc: do not pretend to support all signals
msvc: add pragmas for common warnings
msvc: add a compile-time flag to allow detailed heap debugging
msvc: support building Git using MS Visual C++
msvc: update Makefile to allow for spaces in the compiler path
msvc: fix detect_msys_tty()
msvc: define ftello()
msvc: do not re-declare the timespec struct
msvc: mark a variable as non-const
msvc: define O_ACCMODE
msvc: include sigset_t definition
msvc: fix dependencies of compat/msvc.c
mingw: replace mingw_startup() hack
obstack: fix compiler warning
cache-tree/blame: avoid reusing the DEBUG constant
t0001 (mingw): do not expect a specific order of stdout/stderr
Mark .bat files as requiring CR/LF endings
mingw: fix a typo in the msysGit-specific section

1  2 
.gitignore
Makefile
compat/winansi.c
t/t0001-init.sh
diff --combined .gitignore
index 40326140c740b57971ba89c5324aaa053d84f8cd,30536f04d62cf6b393824906b12fc0d1b4be6365..e096e0a51c19966eb743454fab50d232441008ca
  /git-request-pull
  /git-rerere
  /git-reset
 +/git-restore
  /git-rev-list
  /git-rev-parse
  /git-revert
  /git-submodule
  /git-submodule--helper
  /git-svn
 +/git-switch
  /git-symbolic-ref
  /git-tag
  /git-unpack-file
  *.user
  *.idb
  *.pdb
+ *.ilk
+ *.iobj
+ *.ipdb
+ *.dll
+ .vs/
  /Debug/
  /Release/
  *.dSYM
diff --combined Makefile
index a6bbe3c407604192260edaa9ef0a0da04175a05a,adb831e95f625bb25c027129f89403e79eab663c..98a0588416c4f3f7a5b48ad72a6c2fd54ff94120
+++ b/Makefile
@@@ -771,11 -771,9 +771,11 @@@ BUILT_INS += git-format-patch$
  BUILT_INS += git-fsck-objects$X
  BUILT_INS += git-init$X
  BUILT_INS += git-merge-subtree$X
 +BUILT_INS += git-restore$X
  BUILT_INS += git-show$X
  BUILT_INS += git-stage$X
  BUILT_INS += git-status$X
 +BUILT_INS += git-switch$X
  BUILT_INS += git-whatchanged$X
  
  # what 'all' will build and 'install' will install in gitexecdir,
@@@ -1237,7 -1235,7 +1237,7 @@@ endi
  
  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)|'
+ 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'
@@@ -2860,6 -2858,33 +2860,33 @@@ install: al
        $(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
        $(INSTALL) -m 644 $(SCRIPT_LIB) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
        $(INSTALL) $(install_bindir_programs) '$(DESTDIR_SQ)$(bindir_SQ)'
+ ifdef MSVC
+       # We DO NOT install the individual foo.o.pdb files because they
+       # have already been rolled up into the exe's pdb file.
+       # We DO NOT have pdb files for the builtin commands (like git-status.exe)
+       # because it is just a copy/hardlink of git.exe, rather than a unique binary.
+       $(INSTALL) git.pdb '$(DESTDIR_SQ)$(bindir_SQ)'
+       $(INSTALL) git-shell.pdb '$(DESTDIR_SQ)$(bindir_SQ)'
+       $(INSTALL) git-upload-pack.pdb '$(DESTDIR_SQ)$(bindir_SQ)'
+       $(INSTALL) git-credential-store.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
+       $(INSTALL) git-daemon.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
+       $(INSTALL) git-fast-import.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
+       $(INSTALL) git-http-backend.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
+       $(INSTALL) git-http-fetch.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
+       $(INSTALL) git-http-push.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
+       $(INSTALL) git-imap-send.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
+       $(INSTALL) git-remote-http.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
+       $(INSTALL) git-remote-testsvn.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
+       $(INSTALL) git-sh-i18n--envsubst.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
+       $(INSTALL) git-show-index.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
+ ifndef DEBUG
+       $(INSTALL) $(vcpkg_rel_bin)/*.dll '$(DESTDIR_SQ)$(bindir_SQ)'
+       $(INSTALL) $(vcpkg_rel_bin)/*.pdb '$(DESTDIR_SQ)$(bindir_SQ)'
+ else
+       $(INSTALL) $(vcpkg_dbg_bin)/*.dll '$(DESTDIR_SQ)$(bindir_SQ)'
+       $(INSTALL) $(vcpkg_dbg_bin)/*.pdb '$(DESTDIR_SQ)$(bindir_SQ)'
+ endif
+ endif
        $(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install
        $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(mergetools_instdir_SQ)'
        $(INSTALL) -m 644 mergetools/* '$(DESTDIR_SQ)$(mergetools_instdir_SQ)'
@@@ -3072,6 -3097,19 +3099,19 @@@ endi
        $(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-BUILD-OPTIONS
        $(RM) GIT-USER-AGENT GIT-PREFIX
        $(RM) GIT-SCRIPT-DEFINES GIT-PERL-DEFINES GIT-PERL-HEADER GIT-PYTHON-VARS
+ ifdef MSVC
+       $(RM) $(patsubst %.o,%.o.pdb,$(OBJECTS))
+       $(RM) $(patsubst %.exe,%.pdb,$(OTHER_PROGRAMS))
+       $(RM) $(patsubst %.exe,%.iobj,$(OTHER_PROGRAMS))
+       $(RM) $(patsubst %.exe,%.ipdb,$(OTHER_PROGRAMS))
+       $(RM) $(patsubst %.exe,%.pdb,$(PROGRAMS))
+       $(RM) $(patsubst %.exe,%.iobj,$(PROGRAMS))
+       $(RM) $(patsubst %.exe,%.ipdb,$(PROGRAMS))
+       $(RM) $(patsubst %.exe,%.pdb,$(TEST_PROGRAMS))
+       $(RM) $(patsubst %.exe,%.iobj,$(TEST_PROGRAMS))
+       $(RM) $(patsubst %.exe,%.ipdb,$(TEST_PROGRAMS))
+       $(RM) compat/vcbuild/MSVC-DEFS-GEN
+ endif
  
  .PHONY: all install profile-clean cocciclean clean strip
  .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
diff --combined compat/winansi.c
index a29d34ef44864f02bd89c8490d38bca0efe2a8e6,11cd9b82cc8909b5316d63a0fe35ad8b6c45c096..efc0abcdac43e1c126d6d8148b8a03392e4ae911
@@@ -7,7 -7,6 +7,7 @@@
  #include <wingdi.h>
  #include <winreg.h>
  #include "win32.h"
 +#include "win32/lazyload.h"
  
  static int fd_is_interactive[3] = { 0, 0, 0 };
  #define FD_CONSOLE 0x1
@@@ -42,21 -41,26 +42,21 @@@ typedef struct _CONSOLE_FONT_INFOEX 
  #endif
  #endif
  
 -typedef BOOL (WINAPI *PGETCURRENTCONSOLEFONTEX)(HANDLE, BOOL,
 -              PCONSOLE_FONT_INFOEX);
 -
  static void warn_if_raster_font(void)
  {
        DWORD fontFamily = 0;
 -      PGETCURRENTCONSOLEFONTEX pGetCurrentConsoleFontEx;
 +      DECLARE_PROC_ADDR(kernel32.dll, BOOL, GetCurrentConsoleFontEx,
 +                      HANDLE, BOOL, PCONSOLE_FONT_INFOEX);
  
        /* don't bother if output was ascii only */
        if (!non_ascii_used)
                return;
  
        /* GetCurrentConsoleFontEx is available since Vista */
 -      pGetCurrentConsoleFontEx = (PGETCURRENTCONSOLEFONTEX) GetProcAddress(
 -                      GetModuleHandle("kernel32.dll"),
 -                      "GetCurrentConsoleFontEx");
 -      if (pGetCurrentConsoleFontEx) {
 +      if (INIT_PROC_ADDR(GetCurrentConsoleFontEx)) {
                CONSOLE_FONT_INFOEX cfi;
                cfi.cbSize = sizeof(cfi);
 -              if (pGetCurrentConsoleFontEx(console, 0, &cfi))
 +              if (GetCurrentConsoleFontEx(console, 0, &cfi))
                        fontFamily = cfi.FontFamily;
        } else {
                /* pre-Vista: check default console font in registry */
@@@ -540,7 -544,20 +540,20 @@@ static HANDLE swap_osfhnd(int fd, HANDL
  #ifdef DETECT_MSYS_TTY
  
  #include <winternl.h>
+ #if defined(_MSC_VER)
+ typedef struct _OBJECT_NAME_INFORMATION
+ {
+       UNICODE_STRING Name;
+       WCHAR NameBuffer[0];
+ } OBJECT_NAME_INFORMATION, *POBJECT_NAME_INFORMATION;
+ #define ObjectNameInformation 1
+ #else
  #include <ntstatus.h>
+ #endif
  
  static void detect_msys_tty(int fd)
  {
diff --combined t/t0001-init.sh
index 77c5ed6a18e7849c4b823f9056dfb34cca951e15,1f759b08f2010e968e3f35b86594f9bcd31f8a8b..26f82063267f3043f7f9c36745d913c12dbe0a27
@@@ -311,8 -311,8 +311,8 @@@ test_expect_success 'init prefers comma
  test_expect_success 'init with separate gitdir' '
        rm -rf newdir &&
        git init --separate-git-dir realgitdir newdir &&
 -      echo "gitdir: $(pwd)/realgitdir" >expected &&
 -      test_cmp expected newdir/.git &&
 +      newdir_git="$(cat newdir/.git)" &&
 +      test_cmp_fspath "$(pwd)/realgitdir" "${newdir_git#gitdir: }" &&
        test_path_is_dir realgitdir/refs
  '
  
@@@ -361,9 -361,12 +361,9 @@@ test_expect_success 're-init on .git fi
  '
  
  test_expect_success 're-init to update git link' '
 -      (
 -      cd newdir &&
 -      git init --separate-git-dir ../surrealgitdir
 -      ) &&
 -      echo "gitdir: $(pwd)/surrealgitdir" >expected &&
 -      test_cmp expected newdir/.git &&
 +      git -C newdir init --separate-git-dir ../surrealgitdir &&
 +      newdir_git="$(cat newdir/.git)" &&
 +      test_cmp_fspath "$(pwd)/surrealgitdir" "${newdir_git#gitdir: }" &&
        test_path_is_dir surrealgitdir/refs &&
        test_path_is_missing realgitdir/refs
  '
  test_expect_success 're-init to move gitdir' '
        rm -rf newdir realgitdir surrealgitdir &&
        git init newdir &&
 -      (
 -      cd newdir &&
 -      git init --separate-git-dir ../realgitdir
 -      ) &&
 -      echo "gitdir: $(pwd)/realgitdir" >expected &&
 -      test_cmp expected newdir/.git &&
 +      git -C newdir init --separate-git-dir ../realgitdir &&
 +      newdir_git="$(cat newdir/.git)" &&
 +      test_cmp_fspath "$(pwd)/realgitdir" "${newdir_git#gitdir: }" &&
        test_path_is_dir realgitdir/refs
  '
  
@@@ -467,8 -473,8 +467,8 @@@ test_expect_success MINGW 'redirect st
                GIT_REDIRECT_STDOUT=output.txt \
                GIT_REDIRECT_STDERR="2>&1" \
                git rev-parse --git-dir --verify refs/invalid &&
-       printf ".git\nfatal: Needed a single revision\n" >expect &&
-       test_cmp expect output.txt
+       grep "^\\.git\$" output.txt &&
+       grep "Needed a single revision" output.txt
  '
  
  test_done