Git fork

mingw: rename WIN32 cpp macro to GIT_WINDOWS_NATIVE

Throughout git, it is assumed that the WIN32 preprocessor symbol is
defined on native Windows setups (mingw and msvc) and not on Cygwin.
On Cygwin, most of the time git can pretend this is just another Unix
machine, and Windows-specific magic is generally counterproductive.

Unfortunately Cygwin *does* define the WIN32 symbol in some headers.
Best to rely on a new git-specific symbol GIT_WINDOWS_NATIVE instead,
defined as follows:

#if defined(WIN32) && !defined(__CYGWIN__)
# define GIT_WINDOWS_NATIVE
#endif

After this change, it should be possible to drop the
CYGWIN_V15_WIN32API setting without any negative effect.

[rj: %s/WINDOWS_NATIVE/GIT_WINDOWS_NATIVE/g ]

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Jonathan Nieder and committed by
Junio C Hamano
380395d0 b75cdfaa

+15 -14
+1 -1
abspath.c
··· 216 216 const char *prefix_filename(const char *pfx, int pfx_len, const char *arg) 217 217 { 218 218 static char path[PATH_MAX]; 219 - #ifndef WIN32 219 + #ifndef GIT_WINDOWS_NATIVE 220 220 if (!pfx_len || is_absolute_path(arg)) 221 221 return arg; 222 222 memcpy(path, pfx, pfx_len);
+2 -2
compat/terminal.c
··· 3 3 #include "sigchain.h" 4 4 #include "strbuf.h" 5 5 6 - #if defined(HAVE_DEV_TTY) || defined(WIN32) 6 + #if defined(HAVE_DEV_TTY) || defined(GIT_WINDOWS_NATIVE) 7 7 8 8 static void restore_term(void); 9 9 ··· 53 53 return -1; 54 54 } 55 55 56 - #elif defined(WIN32) 56 + #elif defined(GIT_WINDOWS_NATIVE) 57 57 58 58 #define INPUT_PATH "CONIN$" 59 59 #define OUTPUT_PATH "CONOUT$"
+1 -1
compat/win32.h
··· 2 2 #define WIN32_H 3 3 4 4 /* common Win32 functions for MinGW and Cygwin */ 5 - #ifndef WIN32 /* Not defined by Cygwin */ 5 + #ifndef GIT_WINDOWS_NATIVE /* Not defined for Cygwin */ 6 6 #include <windows.h> 7 7 #endif 8 8
+1 -1
diff-no-index.c
··· 45 45 46 46 if (!path || !strcmp(path, "/dev/null")) 47 47 *mode = 0; 48 - #ifdef _WIN32 48 + #ifdef GIT_WINDOWS_NATIVE 49 49 else if (!strcasecmp(path, "nul")) 50 50 *mode = 0; 51 51 #endif
+2 -1
git-compat-util.h
··· 85 85 #define _NETBSD_SOURCE 1 86 86 #define _SGI_SOURCE 1 87 87 88 - #ifdef WIN32 /* Both MinGW and MSVC */ 88 + #if defined(WIN32) && !defined(__CYGWIN__) /* Both MinGW and MSVC */ 89 89 # if defined (_MSC_VER) 90 90 # define _WIN32_WINNT 0x0502 91 91 # endif 92 92 #define WIN32_LEAN_AND_MEAN /* stops windows.h including winsock.h */ 93 93 #include <winsock2.h> 94 94 #include <windows.h> 95 + #define GIT_WINDOWS_NATIVE 95 96 #endif 96 97 97 98 #include <unistd.h>
+1 -1
help.c
··· 106 106 !S_ISREG(st.st_mode)) 107 107 return 0; 108 108 109 - #if defined(WIN32) || defined(__CYGWIN__) 109 + #if defined(GIT_WINDOWS_NATIVE) || defined(__CYGWIN__) 110 110 #if defined(__CYGWIN__) 111 111 if ((st.st_mode & S_IXUSR) == 0) 112 112 #endif
+5 -5
run-command.c
··· 72 72 close(fd[1]); 73 73 } 74 74 75 - #ifndef WIN32 75 + #ifndef GIT_WINDOWS_NATIVE 76 76 static inline void dup_devnull(int to) 77 77 { 78 78 int fd = open("/dev/null", O_RDWR); ··· 159 159 die("BUG: shell command is empty"); 160 160 161 161 if (strcspn(argv[0], "|&;<>()$`\\\"' \t\n*?[#~=%") != strlen(argv[0])) { 162 - #ifndef WIN32 162 + #ifndef GIT_WINDOWS_NATIVE 163 163 nargv[nargc++] = SHELL_PATH; 164 164 #else 165 165 nargv[nargc++] = "sh"; ··· 182 182 return nargv; 183 183 } 184 184 185 - #ifndef WIN32 185 + #ifndef GIT_WINDOWS_NATIVE 186 186 static int execv_shell_cmd(const char **argv) 187 187 { 188 188 const char **nargv = prepare_shell_cmd(argv); ··· 193 193 } 194 194 #endif 195 195 196 - #ifndef WIN32 196 + #ifndef GIT_WINDOWS_NATIVE 197 197 static int child_err = 2; 198 198 static int child_notifier = -1; 199 199 ··· 334 334 trace_argv_printf(cmd->argv, "trace: run_command:"); 335 335 fflush(NULL); 336 336 337 - #ifndef WIN32 337 + #ifndef GIT_WINDOWS_NATIVE 338 338 { 339 339 int notify_pipe[2]; 340 340 if (pipe(notify_pipe))
+1 -1
test-chmtime.c
··· 87 87 return -1; 88 88 } 89 89 90 - #ifdef WIN32 90 + #ifdef GIT_WINDOWS_NATIVE 91 91 if (!(sb.st_mode & S_IWUSR) && 92 92 chmod(argv[i], sb.st_mode | S_IWUSR)) { 93 93 fprintf(stderr, "Could not make user-writable %s: %s",
+1 -1
thread-utils.c
··· 24 24 long ncpus; 25 25 #endif 26 26 27 - #ifdef _WIN32 27 + #ifdef GIT_WINDOWS_NATIVE 28 28 SYSTEM_INFO info; 29 29 GetSystemInfo(&info); 30 30