{"thread":{"id":"33651","subject":"[PATCH 1/2] mingw: rename WIN32 cpp macro to GIT_NATIVE_WINDOWS","startedAt":"2013-04-27T19:40:46Z","lastAt":"2013-04-29T23:22:56Z","messageCount":4,"participants":["Ramsay Jones","Jonathan Nieder","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"215735","messageId":"517C29BE.6050002@ramsay1.demon.co.uk","threadId":"33651","inReplyTo":null,"subject":"[PATCH 1/2] mingw: rename WIN32 cpp macro to GIT_NATIVE_WINDOWS","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2013-04-27T19:40:46Z","receivedAt":"2013-04-27T19:40:46Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"From: Jonathan Nieder <jrnieder@gmail.com>\n\nThroughout git, it is assumed that the WIN32 preprocessor symbol is\ndefined on native Windows setups (mingw and msvc) and not on Cygwin.\nOn Cygwin, most of the time git can pretend this is just another Unix\nmachine, and Windows-specific magic is generally counterproductive.\n\nUnfortunately Cygwin *does* define the WIN32 symbol in some headers.\nBest to rely on a new git-specific symbol GIT_NATIVE_WINDOWS instead,\ndefined as follows:\n\n\t#if defined(WIN32) && !defined(__CYGWIN__)\n\t# define GIT_NATIVE_WINDOWS\n\t#endif\n\nAfter this change, it should be possible to drop the\nCYGWIN_V15_WIN32API setting without any negative effect.\n\n[rj: %s/NATIVE_WINDOWS/GIT_NATIVE_WINDOWS/g ]\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\nSigned-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>\n---\n abspath.c         |  2 +-\n compat/terminal.c |  4 ++--\n compat/win32.h    |  2 +-\n diff-no-index.c   |  2 +-\n git-compat-util.h |  3 ++-\n help.c            |  2 +-\n run-command.c     | 10 +++++-----\n test-chmtime.c    |  2 +-\n thread-utils.c    |  2 +-\n 9 files changed, 15 insertions(+), 14 deletions(-)\n\ndiff --git a/abspath.c b/abspath.c\nindex 40cdc46..64adbe2 100644\n--- a/abspath.c\n+++ b/abspath.c\n@@ -216,7 +216,7 @@ const char *absolute_path(const char *path)\n const char *prefix_filename(const char *pfx, int pfx_len, const char *arg)\n {\n \tstatic char path[PATH_MAX];\n-#ifndef WIN32\n+#ifndef GIT_WINDOWS_NATIVE\n \tif (!pfx_len || is_absolute_path(arg))\n \t\treturn arg;\n \tmemcpy(path, pfx, pfx_len);\ndiff --git a/compat/terminal.c b/compat/terminal.c\nindex 9b5e3d1..313897d 100644\n--- a/compat/terminal.c\n+++ b/compat/terminal.c\n@@ -3,7 +3,7 @@\n #include \"sigchain.h\"\n #include \"strbuf.h\"\n \n-#if defined(HAVE_DEV_TTY) || defined(WIN32)\n+#if defined(HAVE_DEV_TTY) || defined(GIT_WINDOWS_NATIVE)\n \n static void restore_term(void);\n \n@@ -53,7 +53,7 @@ error:\n \treturn -1;\n }\n \n-#elif defined(WIN32)\n+#elif defined(GIT_WINDOWS_NATIVE)\n \n #define INPUT_PATH \"CONIN$\"\n #define OUTPUT_PATH \"CONOUT$\"\ndiff --git a/compat/win32.h b/compat/win32.h\nindex 8ce9104..a97e880 100644\n--- a/compat/win32.h\n+++ b/compat/win32.h\n@@ -2,7 +2,7 @@\n #define WIN32_H\n \n /* common Win32 functions for MinGW and Cygwin */\n-#ifndef WIN32         /* Not defined by Cygwin */\n+#ifndef GIT_WINDOWS_NATIVE\t/* Not defined for Cygwin */\n #include <windows.h>\n #endif\n \ndiff --git a/diff-no-index.c b/diff-no-index.c\nindex 74da659..e66fdf3 100644\n--- a/diff-no-index.c\n+++ b/diff-no-index.c\n@@ -45,7 +45,7 @@ static int get_mode(const char *path, int *mode)\n \n \tif (!path || !strcmp(path, \"/dev/null\"))\n \t\t*mode = 0;\n-#ifdef _WIN32\n+#ifdef GIT_WINDOWS_NATIVE\n \telse if (!strcasecmp(path, \"nul\"))\n \t\t*mode = 0;\n #endif\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex e955bb5..eeed506 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -85,13 +85,14 @@\n #define _NETBSD_SOURCE 1\n #define _SGI_SOURCE 1\n \n-#ifdef WIN32 /* Both MinGW and MSVC */\n+#if defined(WIN32) && !defined(__CYGWIN__) /* Both MinGW and MSVC */\n # if defined (_MSC_VER)\n #  define _WIN32_WINNT 0x0502\n # endif\n #define WIN32_LEAN_AND_MEAN  /* stops windows.h including winsock.h */\n #include <winsock2.h>\n #include <windows.h>\n+#define GIT_WINDOWS_NATIVE\n #endif\n \n #include <unistd.h>\ndiff --git a/help.c b/help.c\nindex 02ba043..3d70d7a 100644\n--- a/help.c\n+++ b/help.c\n@@ -106,7 +106,7 @@ static int is_executable(const char *name)\n \t    !S_ISREG(st.st_mode))\n \t\treturn 0;\n \n-#if defined(WIN32) || defined(__CYGWIN__)\n+#if defined(GIT_WINDOWS_NATIVE) || defined(__CYGWIN__)\n #if defined(__CYGWIN__)\n if ((st.st_mode & S_IXUSR) == 0)\n #endif\ndiff --git a/run-command.c b/run-command.c\nindex 1b32a12..aece872 100644\n--- a/run-command.c\n+++ b/run-command.c\n@@ -72,7 +72,7 @@ static inline void close_pair(int fd[2])\n \tclose(fd[1]);\n }\n \n-#ifndef WIN32\n+#ifndef GIT_WINDOWS_NATIVE\n static inline void dup_devnull(int to)\n {\n \tint fd = open(\"/dev/null\", O_RDWR);\n@@ -159,7 +159,7 @@ static const char **prepare_shell_cmd(const char **argv)\n \t\tdie(\"BUG: shell command is empty\");\n \n \tif (strcspn(argv[0], \"|&;<>()$`\\\\\\\"' \\t\\n*?[#~=%\") != strlen(argv[0])) {\n-#ifndef WIN32\n+#ifndef GIT_WINDOWS_NATIVE\n \t\tnargv[nargc++] = SHELL_PATH;\n #else\n \t\tnargv[nargc++] = \"sh\";\n@@ -182,7 +182,7 @@ static const char **prepare_shell_cmd(const char **argv)\n \treturn nargv;\n }\n \n-#ifndef WIN32\n+#ifndef GIT_WINDOWS_NATIVE\n static int execv_shell_cmd(const char **argv)\n {\n \tconst char **nargv = prepare_shell_cmd(argv);\n@@ -193,7 +193,7 @@ static int execv_shell_cmd(const char **argv)\n }\n #endif\n \n-#ifndef WIN32\n+#ifndef GIT_WINDOWS_NATIVE\n static int child_err = 2;\n static int child_notifier = -1;\n \n@@ -334,7 +334,7 @@ fail_pipe:\n \ttrace_argv_printf(cmd->argv, \"trace: run_command:\");\n \tfflush(NULL);\n \n-#ifndef WIN32\n+#ifndef GIT_WINDOWS_NATIVE\n {\n \tint notify_pipe[2];\n \tif (pipe(notify_pipe))\ndiff --git a/test-chmtime.c b/test-chmtime.c\nindex 02b42ba..1cffa12 100644\n--- a/test-chmtime.c\n+++ b/test-chmtime.c\n@@ -87,7 +87,7 @@ int main(int argc, const char *argv[])\n \t\t\treturn -1;\n \t\t}\n \n-#ifdef WIN32\n+#ifdef GIT_WINDOWS_NATIVE\n \t\tif (!(sb.st_mode & S_IWUSR) &&\n \t\t\t\tchmod(argv[i], sb.st_mode | S_IWUSR)) {\n \t\t\tfprintf(stderr, \"Could not make user-writable %s: %s\",\ndiff --git a/thread-utils.c b/thread-utils.c\nindex 7f4b76a..97396a7 100644\n--- a/thread-utils.c\n+++ b/thread-utils.c\n@@ -24,7 +24,7 @@ int online_cpus(void)\n \tlong ncpus;\n #endif\n \n-#ifdef _WIN32\n+#ifdef GIT_WINDOWS_NATIVE\n \tSYSTEM_INFO info;\n \tGetSystemInfo(&info);\n \n-- \n1.8.2\n"},{"id":"215823","messageId":"20130429051059.GC8031@elie.Belkin","threadId":"33651","inReplyTo":"517C29BE.6050002@ramsay1.demon.co.uk","subject":"Re: [PATCH 1/2] mingw: rename WIN32 cpp macro to GIT_NATIVE_WINDOWS","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2013-04-29T05:11:00Z","receivedAt":"2013-04-29T05:11:00Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Ramsay Jones wrote:\n\n> After this change, it should be possible to drop the\n> CYGWIN_V15_WIN32API setting without any negative effect.\n>\n> [rj: %s/NATIVE_WINDOWS/GIT_NATIVE_WINDOWS/g ]\n>\n> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>\n> Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>\n\nYay!  Thanks for finishing it.\n\nFor what it's worth,\nReviewed-by: Jonathan Nieder <jrnieder@gmail.com>\n"},{"id":"215830","messageId":"7v38u9opnk.fsf@alter.siamese.dyndns.org","threadId":"33651","inReplyTo":"20130429051059.GC8031@elie.Belkin","subject":"Re: [PATCH 1/2] mingw: rename WIN32 cpp macro to GIT_NATIVE_WINDOWS","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-04-29T05:46:07Z","receivedAt":"2013-04-29T05:46:07Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonathan Nieder <jrnieder@gmail.com> writes:\n\n> Ramsay Jones wrote:\n>\n>> After this change, it should be possible to drop the\n>> CYGWIN_V15_WIN32API setting without any negative effect.\n>>\n>> [rj: %s/NATIVE_WINDOWS/GIT_NATIVE_WINDOWS/g ]\n>>\n>> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>\n>> Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>\n>\n> Yay!  Thanks for finishing it.\n>\n> For what it's worth,\n> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>\n\nWait.  The proposed commit log message talks about native-windows\nbut throughout the code it is windows-native [I'll reword when I\nrebase-i to add your reviewed-by].\n\nWhile I really like seeing an unfinished topic completed by tying\nits loose ends like this patch does, it feels a bit too late for the\ncycle, especially given that we _know_ the changes still need to be\ntested on a platform that the series is expected to affect.\n\nCould somebody who builds regularly on Cygwin 1.7 try to see if\nthese two patches are OK?\n\nReports from people without previous experience with Git on Cygwin\nwho freshly install Cygwin 1.7 only to test these two patches do not\ncount, because they do not know what is expected and cannot tell\nregressions from know limitations.\n\nThanks.\n"},{"id":"215939","messageId":"517F00D0.5010103@ramsay1.demon.co.uk","threadId":"33651","inReplyTo":"7v38u9opnk.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 1/2] mingw: rename WIN32 cpp macro to GIT_NATIVE_WINDOWS","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2013-04-29T23:22:56Z","receivedAt":"2013-04-29T23:22:56Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"Junio C Hamano wrote:\n> Jonathan Nieder <jrnieder@gmail.com> writes:\n>> Ramsay Jones wrote:\n\n[snip]\n\n> While I really like seeing an unfinished topic completed by tying\n> its loose ends like this patch does, it feels a bit too late for the\n> cycle, especially given that we _know_ the changes still need to be\n> tested on a platform that the series is expected to affect.\n\nYes, I suspect it is low risk, but there is no need to include it\nin this cycle.\n\nATB,\nRamsay Jones\n"}]}