{"thread":{"id":"23859","subject":"[PATCH 0/5] Various fixes for Windows","startedAt":"2010-05-20T18:57:50Z","lastAt":"2010-05-20T23:13:23Z","messageCount":7,"participants":["Johannes Sixt","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"141980","messageId":"cover.1274380838.git.j6t@kdbg.org","threadId":"23859","inReplyTo":null,"subject":"[PATCH 0/5] Various fixes for Windows","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2010-05-20T18:57:50Z","receivedAt":"2010-05-20T18:57:50Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Here are some unrelated patches that I had accumulated over the past\nweeks that improve the git experience on Windows.\n\nThe first three are maint-worthy and have been cooked long enough.\nIMO it is safe to put them on maint directly.\n\nErik Faye-Lund (1):\n  mingw: use _commit to implement fsync\n\nIan McLean (1):\n  Fix \"Out of memory? mmap failed\" for files larger than 4GB on Windows\n\nJohannes Sixt (1):\n  Recent MinGW has a C99 implementation of snprintf functions\n\nRené Scharfe (1):\n  Fix checkout of large files to network shares on Windows XP\n\nbert Dvornik (1):\n  start_command: close cmd->err descriptor when fork/spawn fails\n\n Makefile              |    1 -\n compat/mingw.c        |   17 +++++++++++++++++\n compat/mingw.h        |    5 ++++-\n compat/win32mmap.c    |    6 +++---\n run-command.c         |    2 ++\n t/t5516-fetch-push.sh |    2 +-\n t/t5705-clone-2gb.sh  |   12 +++++++++---\n 7 files changed, 36 insertions(+), 9 deletions(-)\n"},{"id":"141981","messageId":"7289ab6b171efda2fbc0f5d5b0080c7f1afd529e.1274380838.git.j6t@kdbg.org","threadId":"23859","inReplyTo":"cover.1274380838.git.j6t@kdbg.org","subject":"[PATCH 1/5 maint] Fix \"Out of memory? mmap failed\" for files larger than 4GB on Windows","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2010-05-20T18:57:51Z","receivedAt":"2010-05-20T18:57:51Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"From: Ian McLean <ian.mclean@gmail.com>\n\nThe git_mmap implementation was broken for file sizes that wouldn't fit\ninto a size_t (32 bits).  This was caused by intermediate variables that\nwere only 32 bits wide when they should be 64 bits.\n\nSigned-off-by: Johannes Sixt <j6t@kdbg.org>\n---\n This patch is obviously correct. I have used it in production to verify\n that it doesn't break repositories that are smaller than 4GB.\n\n compat/win32mmap.c |    6 +++---\n 1 files changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/compat/win32mmap.c b/compat/win32mmap.c\nindex 1c5a149..b58aa69 100644\n--- a/compat/win32mmap.c\n+++ b/compat/win32mmap.c\n@@ -4,19 +4,19 @@ void *git_mmap(void *start, size_t length, int prot, int flags, int fd, off_t of\n {\n \tHANDLE hmap;\n \tvoid *temp;\n-\tsize_t len;\n+\toff_t len;\n \tstruct stat st;\n \tuint64_t o = offset;\n \tuint32_t l = o & 0xFFFFFFFF;\n \tuint32_t h = (o >> 32) & 0xFFFFFFFF;\n \n \tif (!fstat(fd, &st))\n-\t\tlen = xsize_t(st.st_size);\n+\t\tlen = st.st_size;\n \telse\n \t\tdie(\"mmap: could not determine filesize\");\n \n \tif ((length + offset) > len)\n-\t\tlength = len - offset;\n+\t\tlength = xsize_t(len - offset);\n \n \tif (!(flags & MAP_PRIVATE))\n \t\tdie(\"Invalid usage of mmap when built with USE_WIN32_MMAP\");\n-- \n1.7.1.64.ga1799.dirty\n"},{"id":"141982","messageId":"753dbe1c95461e736185f4a1b06e20937dab9db7.1274380838.git.j6t@kdbg.org","threadId":"23859","inReplyTo":"cover.1274380838.git.j6t@kdbg.org","subject":"[PATCH 2/5 maint] start_command: close cmd->err descriptor when fork/spawn fails","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2010-05-20T18:57:52Z","receivedAt":"2010-05-20T18:57:52Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"From: bert Dvornik <dvornik+git@gmail.com>\n\nFix the problem where the cmd->err passed into start_command wasn't\nbeing properly closed when certain types of errors occurr.  (Compare\nthe affected code with the clean shutdown code later in the function.)\n\nOn Windows, this problem would be triggered if mingw_spawnvpe()\nfailed, which would happen if the command to be executed was malformed\n(e.g. a text file that didn't start with a #! line).  If cmd->err was\na pipe, the failure to close it could result in a hang while the other\nside was waiting (forever) for either input or pipe close, e.g. while\ntrying to shove the output into the side band.  On msysGit, this\nproblem was causing a hang in t5516-fetch-push.\n\n[J6t: With a slight adjustment of the test case, the hang is also\nobserved on Linux.]\n\nSigned-off-by: bert Dvornik <dvornik+git@gmail.com>\nSigned-off-by: Johannes Sixt <j6t@kdbg.org>\n---\n run-command.c         |    2 ++\n t/t5516-fetch-push.sh |    2 +-\n 2 files changed, 3 insertions(+), 1 deletions(-)\n\ndiff --git a/run-command.c b/run-command.c\nindex eb5c575..c7793f5 100644\n--- a/run-command.c\n+++ b/run-command.c\n@@ -383,6 +383,8 @@ fail_pipe:\n \t\t\tclose(cmd->out);\n \t\tif (need_err)\n \t\t\tclose_pair(fderr);\n+\t\telse if (cmd->err)\n+\t\t\tclose(cmd->err);\n \t\terrno = failed_errno;\n \t\treturn -1;\n \t}\ndiff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh\nindex 2de98e6..6a37a4d 100755\n--- a/t/t5516-fetch-push.sh\n+++ b/t/t5516-fetch-push.sh\n@@ -528,7 +528,7 @@ test_expect_success 'push does not update local refs on failure' '\n \tmk_test heads/master &&\n \tmk_child child &&\n \tmkdir testrepo/.git/hooks &&\n-\techo exit 1 >testrepo/.git/hooks/pre-receive &&\n+\techo \"#!/no/frobnication/today\" >testrepo/.git/hooks/pre-receive &&\n \tchmod +x testrepo/.git/hooks/pre-receive &&\n \t(cd child &&\n \t\tgit pull .. master\n-- \n1.7.1.64.ga1799.dirty\n"},{"id":"141983","messageId":"7b0bf230bfc68ff9590e78f42bb52f27b81ab6f5.1274380838.git.j6t@kdbg.org","threadId":"23859","inReplyTo":"cover.1274380838.git.j6t@kdbg.org","subject":"[PATCH 3/5 maint] Fix checkout of large files to network shares on Windows XP","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2010-05-20T18:57:53Z","receivedAt":"2010-05-20T18:57:53Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"From: René Scharfe <rene.scharfe@lsrfire.ath.cx>\n\nBigger writes to network drives on Windows XP fail.  Cap them at 31MB to\nallow them to succeed.  Callers need to be prepared for write() calls\nthat do less work than requested anyway.\n\nOn local drives, write() calls are translated to WriteFile() calls with\na cap of 64KB on Windows XP and 256KB on Vista.  Thus a cap of 31MB won't\naffect the number of WriteFile() calls which do the actual work.  There's\nstill room for some other version of Windows to use a chunk size of 1MB\nwithout increasing the number of system calls.\n\nSigned-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>\nSigned-off-by: Johannes Sixt <j6t@kdbg.org>\n---\n Again, I've used this patch in production with smaller repositories,\n and it worked flawlessly.\n\n compat/mingw.c       |   17 +++++++++++++++++\n compat/mingw.h       |    3 +++\n t/t5705-clone-2gb.sh |   12 +++++++++---\n 3 files changed, 29 insertions(+), 3 deletions(-)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex f90a114..9a8e336 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -140,6 +140,23 @@ int mingw_open (const char *filename, int oflags, ...)\n \treturn fd;\n }\n \n+#undef write\n+ssize_t mingw_write(int fd, const void *buf, size_t count)\n+{\n+\t/*\n+\t * While write() calls to a file on a local disk are translated\n+\t * into WriteFile() calls with a maximum size of 64KB on Windows\n+\t * XP and 256KB on Vista, no such cap is placed on writes to\n+\t * files over the network on Windows XP.  Unfortunately, there\n+\t * seems to be a limit of 32MB-28KB on X64 and 64MB-32KB on x86;\n+\t * bigger writes fail on Windows XP.\n+\t * So we cap to a nice 31MB here to avoid write failures over\n+\t * the net without changing the number of WriteFile() calls in\n+\t * the local case.\n+\t */\n+\treturn write(fd, buf, min(count, 31 * 1024 * 1024));\n+}\n+\n #undef fopen\n FILE *mingw_fopen (const char *filename, const char *otype)\n {\ndiff --git a/compat/mingw.h b/compat/mingw.h\nindex a6b8778..f465566 100644\n--- a/compat/mingw.h\n+++ b/compat/mingw.h\n@@ -170,6 +170,9 @@ int link(const char *oldpath, const char *newpath);\n int mingw_open (const char *filename, int oflags, ...);\n #define open mingw_open\n \n+ssize_t mingw_write(int fd, const void *buf, size_t count);\n+#define write mingw_write\n+\n FILE *mingw_fopen (const char *filename, const char *otype);\n #define fopen mingw_fopen\n \ndiff --git a/t/t5705-clone-2gb.sh b/t/t5705-clone-2gb.sh\nindex adfaae8..8afbdd4 100755\n--- a/t/t5705-clone-2gb.sh\n+++ b/t/t5705-clone-2gb.sh\n@@ -12,7 +12,7 @@ test_expect_success 'setup' '\n \n \tgit config pack.compression 0 &&\n \tgit config pack.depth 0 &&\n-\tblobsize=$((20*1024*1024)) &&\n+\tblobsize=$((100*1024*1024)) &&\n \tblobcount=$((2*1024*1024*1024/$blobsize+1)) &&\n \ti=1 &&\n \t(while test $i -le $blobcount\n@@ -36,9 +36,15 @@ test_expect_success 'setup' '\n \n '\n \n-test_expect_success 'clone' '\n+test_expect_success 'clone - bare' '\n \n-\tgit clone --bare --no-hardlinks . clone\n+\tgit clone --bare --no-hardlinks . clone-bare\n+\n+'\n+\n+test_expect_success 'clone - with worktree, file:// protocol' '\n+\n+\tgit clone file://. clone-wt\n \n '\n \n-- \n1.7.1.64.ga1799.dirty\n"},{"id":"141984","messageId":"d9c55801e8ea50fafbc3ea5de0f7f084984418de.1274380838.git.j6t@kdbg.org","threadId":"23859","inReplyTo":"cover.1274380838.git.j6t@kdbg.org","subject":"[PATCH 4/5] mingw: use _commit to implement fsync","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2010-05-20T18:57:54Z","receivedAt":"2010-05-20T18:57:54Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"From: Erik Faye-Lund <kusmabite@googlemail.com>\n\nSigned-off-by: Erik Faye-Lund <kusmabite@gmail.com>\nSigned-off-by: Johannes Sixt <j6t@kdbg.org>\n---\n compat/mingw.h |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/compat/mingw.h b/compat/mingw.h\nindex 7c2ab64..a6b8778 100644\n--- a/compat/mingw.h\n+++ b/compat/mingw.h\n@@ -80,7 +80,7 @@ static inline int fork(void)\n static inline unsigned int alarm(unsigned int seconds)\n { return 0; }\n static inline int fsync(int fd)\n-{ return 0; }\n+{ return _commit(fd); }\n static inline int getppid(void)\n { return 1; }\n static inline void sync(void)\n-- \n1.7.1.64.ga1799.dirty\n"},{"id":"141985","messageId":"439f0b3d51f9548b72e0e719d590cc9bcf4c0084.1274380838.git.j6t@kdbg.org","threadId":"23859","inReplyTo":"cover.1274380838.git.j6t@kdbg.org","subject":"[PATCH 5/5] Recent MinGW has a C99 implementation of snprintf functions","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2010-05-20T18:57:55Z","receivedAt":"2010-05-20T18:57:55Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Date: Mon, 20 Jul 2009 22:15:07 +0200\n\nStarting with MinGW 3.14, released end of 2007, a working snprintf\nis available. This means we do not need our own replacement that works\naround the broken implementation in Microsoft's C runtime.\n\nPeople who build git in an old MinGW environment are expected to set\nSNPRINTF_RETURNS_BOGUS in their config.mak. msysgit is sufficiently\nrecent, of course.\n\nSigned-off-by: Johannes Sixt <j6t@kdbg.org>\n---\n The Date: line is deliberate to show how long I carry this patch. :-)\n\n Makefile |    1 -\n 1 files changed, 0 insertions(+), 1 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 910f471..c36c5b0 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1026,7 +1026,6 @@ ifneq (,$(findstring MINGW,$(uname_S)))\n \tNO_STRTOUMAX = YesPlease\n \tNO_MKDTEMP = YesPlease\n \tNO_MKSTEMPS = YesPlease\n-\tSNPRINTF_RETURNS_BOGUS = YesPlease\n \tNO_SVN_TESTS = YesPlease\n \tNO_PERL_MAKEMAKER = YesPlease\n \tRUNTIME_PREFIX = YesPlease\n-- \n1.7.1.64.ga1799.dirty\n"},{"id":"141993","messageId":"7v7hmy6ub0.fsf@alter.siamese.dyndns.org","threadId":"23859","inReplyTo":"cover.1274380838.git.j6t@kdbg.org","subject":"Re: [PATCH 0/5] Various fixes for Windows","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-05-20T23:13:23Z","receivedAt":"2010-05-20T23:13:23Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks.\n"}]}