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