{"thread":{"id":"36888","subject":"[PATCH 6/7] Win32: Unicode arguments (incoming)","startedAt":"2014-06-11T09:37:39Z","lastAt":"2014-06-18T21:35:12Z","messageCount":12,"participants":["Stepan Kasal","Karsten Blees","Junio C Hamano","Johannes Sixt"],"isPatch":true,"patchVersion":1,"patchTotal":7},"messages":[{"id":"243890","messageId":"1402479466-8500-1-git-send-email-kasal@ucw.cz","threadId":"36888","inReplyTo":null,"subject":"[PATCH 0/7] Second part of msysgit/unicode","fromName":"Stepan Kasal","fromEmail":"kasal@ucw.cz","sentAt":"2014-06-11T09:37:39Z","receivedAt":"2014-06-11T09:37:39Z","isPatch":true,"sender":{"key":"kasal@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/1481596?v=4"},"body":"This is the second part of the time-proven unicode suport branch from msysgit.\nThis batch is a collection of small independent changes, limited to mingw.c.\nThe only exception is the last patch: it changes gitk and git-gui.\n\n(The third and last part of msysgit/unicode branch will all be about\nenvironment handling.)\n\nJohannes Schindelin (1):\n  Let mingw_execve() return an int\n\nKarsten Blees (6):\n  Win32: simplify internal mingw_spawn* APIs\n  Win32: fix potential multi-threading issue\n  MinGW: disable CRT command line globbing\n  Win32: Unicode arguments (outgoing)\n  Win32: Unicode arguments (incoming)\n    - also contains small part of 8c452ca Win32: use low-level memory alloc...\n  Unicode file name support (gitk and git-gui)\n\n compat/mingw.c          | 94 +++++++++++++++++++++++++++++++++++++------------\n git-gui/git-gui.sh      | 11 +++---\n git-gui/lib/browser.tcl |  2 +-\n git-gui/lib/index.tcl   |  6 ++--\n gitk-git/gitk           | 15 ++++----\n 5 files changed, 90 insertions(+), 38 deletions(-)\n\n-- \n2.0.0.9635.g0be03cb\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"243892","messageId":"1402479466-8500-2-git-send-email-kasal@ucw.cz","threadId":"36888","inReplyTo":"1402479466-8500-1-git-send-email-kasal@ucw.cz","subject":"[PATCH 1/7] Let mingw_execve() return an int","fromName":"Stepan Kasal","fromEmail":"kasal@ucw.cz","sentAt":"2014-06-11T09:37:40Z","receivedAt":"2014-06-11T09:37:40Z","isPatch":true,"sender":{"key":"kasal@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/1481596?v=4"},"body":"From: Johannes Schindelin <johannes.schindelin@gmx.de>\nDate: Mon, 28 May 2012 21:21:39 -0500\n\nThis is in the great tradition of POSIX. Original fix by Olivier Refalo.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\nSigned-off-by: Stepan Kasal <kasal@ucw.cz>\n---\n compat/mingw.c | 5 +++--\n 1 file changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex d242557..7da73fa 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -1019,7 +1019,7 @@ static int try_shell_exec(const char *cmd, char *const *argv, char **env)\n \treturn pid;\n }\n \n-static void mingw_execve(const char *cmd, char *const *argv, char *const *env)\n+static int mingw_execve(const char *cmd, char *const *argv, char *const *env)\n {\n \t/* check if git_command is a shell script */\n \tif (!try_shell_exec(cmd, argv, (char **)env)) {\n@@ -1027,11 +1027,12 @@ static void mingw_execve(const char *cmd, char *const *argv, char *const *env)\n \n \t\tpid = mingw_spawnve(cmd, (const char **)argv, (char **)env, 0);\n \t\tif (pid < 0)\n-\t\t\treturn;\n+\t\t\treturn -1;\n \t\tif (waitpid(pid, &status, 0) < 0)\n \t\t\tstatus = 255;\n \t\texit(status);\n \t}\n+\treturn -1;\n }\n \n int mingw_execvp(const char *cmd, char *const *argv)\n-- \n2.0.0.9635.g0be03cb\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"243896","messageId":"1402479466-8500-3-git-send-email-kasal@ucw.cz","threadId":"36888","inReplyTo":"1402479466-8500-1-git-send-email-kasal@ucw.cz","subject":"[PATCH 2/7] Win32: simplify internal mingw_spawn* APIs","fromName":"Stepan Kasal","fromEmail":"kasal@ucw.cz","sentAt":"2014-06-11T09:37:41Z","receivedAt":"2014-06-11T09:37:41Z","isPatch":true,"sender":{"key":"kasal@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/1481596?v=4"},"body":"From: Karsten Blees <blees@dcon.de>\nDate: Fri, 25 Nov 2011 21:33:17 +0100\n\nThe only public spawn function that needs to tweak the environment is\nmingw_spawnvpe (called from start_command). Nevertheless, all internal\nspawn* functions take an env parameter and needlessly pass the global\nchar **environ around. Remove the env parameter where it's not needed.\n\nThis removes the internal mingw_execve abstraction, which is no longer\nneeded.\n\nSigned-off-by: Karsten Blees <blees@dcon.de>\nSigned-off-by: Stepan Kasal <kasal@ucw.cz>\n---\n compat/mingw.c | 23 ++++++++---------------\n 1 file changed, 8 insertions(+), 15 deletions(-)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex 7da73fa..1c0b153 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -941,10 +941,9 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **env,\n \treturn (pid_t)pi.dwProcessId;\n }\n \n-static pid_t mingw_spawnve(const char *cmd, const char **argv, char **env,\n-\t\t\t   int prepend_cmd)\n+static pid_t mingw_spawnv(const char *cmd, const char **argv, int prepend_cmd)\n {\n-\treturn mingw_spawnve_fd(cmd, argv, env, NULL, prepend_cmd, 0, 1, 2);\n+\treturn mingw_spawnve_fd(cmd, argv, environ, NULL, prepend_cmd, 0, 1, 2);\n }\n \n pid_t mingw_spawnvpe(const char *cmd, const char **argv, char **env,\n@@ -986,7 +985,7 @@ pid_t mingw_spawnvpe(const char *cmd, const char **argv, char **env,\n \treturn pid;\n }\n \n-static int try_shell_exec(const char *cmd, char *const *argv, char **env)\n+static int try_shell_exec(const char *cmd, char *const *argv)\n {\n \tconst char *interpr = parse_interpreter(cmd);\n \tchar **path;\n@@ -1004,7 +1003,7 @@ static int try_shell_exec(const char *cmd, char *const *argv, char **env)\n \t\targv2 = xmalloc(sizeof(*argv) * (argc+1));\n \t\targv2[0] = (char *)cmd;\t/* full path to the script file */\n \t\tmemcpy(&argv2[1], &argv[1], sizeof(*argv) * argc);\n-\t\tpid = mingw_spawnve(prog, argv2, env, 1);\n+\t\tpid = mingw_spawnv(prog, argv2, 1);\n \t\tif (pid >= 0) {\n \t\t\tint status;\n \t\t\tif (waitpid(pid, &status, 0) < 0)\n@@ -1019,13 +1018,13 @@ static int try_shell_exec(const char *cmd, char *const *argv, char **env)\n \treturn pid;\n }\n \n-static int mingw_execve(const char *cmd, char *const *argv, char *const *env)\n+int mingw_execv(const char *cmd, char *const *argv)\n {\n \t/* check if git_command is a shell script */\n-\tif (!try_shell_exec(cmd, argv, (char **)env)) {\n+\tif (!try_shell_exec(cmd, argv)) {\n \t\tint pid, status;\n \n-\t\tpid = mingw_spawnve(cmd, (const char **)argv, (char **)env, 0);\n+\t\tpid = mingw_spawnv(cmd, (const char **)argv, 0);\n \t\tif (pid < 0)\n \t\t\treturn -1;\n \t\tif (waitpid(pid, &status, 0) < 0)\n@@ -1041,7 +1040,7 @@ int mingw_execvp(const char *cmd, char *const *argv)\n \tchar *prog = path_lookup(cmd, path, 0);\n \n \tif (prog) {\n-\t\tmingw_execve(prog, argv, environ);\n+\t\tmingw_execv(prog, argv);\n \t\tfree(prog);\n \t} else\n \t\terrno = ENOENT;\n@@ -1050,12 +1049,6 @@ int mingw_execvp(const char *cmd, char *const *argv)\n \treturn -1;\n }\n \n-int mingw_execv(const char *cmd, char *const *argv)\n-{\n-\tmingw_execve(cmd, argv, environ);\n-\treturn -1;\n-}\n-\n int mingw_kill(pid_t pid, int sig)\n {\n \tif (pid > 0 && sig == SIGTERM) {\n-- \n2.0.0.9635.g0be03cb\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"243893","messageId":"1402479466-8500-4-git-send-email-kasal@ucw.cz","threadId":"36888","inReplyTo":"1402479466-8500-1-git-send-email-kasal@ucw.cz","subject":"[PATCH 3/7] Win32: fix potential multi-threading issue","fromName":"Stepan Kasal","fromEmail":"kasal@ucw.cz","sentAt":"2014-06-11T09:37:42Z","receivedAt":"2014-06-11T09:37:42Z","isPatch":true,"sender":{"key":"kasal@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/1481596?v=4"},"body":"From: Karsten Blees <blees@dcon.de>\nDate: Fri, 7 Jan 2011 18:04:16 +0100\n\n...by removing a static buffer in do_stat_internal.\n\nSigned-off-by: Karsten Blees <blees@dcon.de>\nSigned-off-by: Erik Faye-Lund <kusmabite@gmail.com>\nSigned-off-by: Stepan Kasal <kasal@ucw.cz>\n---\n compat/mingw.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex 1c0b153..6849815 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -441,7 +441,7 @@ static int do_lstat(int follow, const char *file_name, struct stat *buf)\n static int do_stat_internal(int follow, const char *file_name, struct stat *buf)\n {\n \tint namelen;\n-\tstatic char alt_name[PATH_MAX];\n+\tchar alt_name[PATH_MAX];\n \n \tif (!do_lstat(follow, file_name, buf))\n \t\treturn 0;\n-- \n2.0.0.9635.g0be03cb\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"243894","messageId":"1402479466-8500-5-git-send-email-kasal@ucw.cz","threadId":"36888","inReplyTo":"1402479466-8500-1-git-send-email-kasal@ucw.cz","subject":"[PATCH 4/7] MinGW: disable CRT command line globbing","fromName":"Stepan Kasal","fromEmail":"kasal@ucw.cz","sentAt":"2014-06-11T09:37:43Z","receivedAt":"2014-06-11T09:37:43Z","isPatch":true,"sender":{"key":"kasal@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/1481596?v=4"},"body":"From: Karsten Blees <blees@dcon.de>\nDate: Fri, 7 Jan 2011 19:52:20 +0100\n\nMingwRT listens to _CRT_glob to decide if __getmainargs should\nperform globbing, with the default being that it should.\nUnfortunately, __getmainargs globbing is sub-par; for instance\npatterns like \"*.c\" will only match c-sources in the current\ndirectory.\n\nDisable __getmainargs' command line wildcard expansion, so these\npatterns will be left untouched, and handled by Git's superior\nbuilt-in globbing instead.\n\nMSVC defaults to no globbing, so we don't need to do anything\nin that case.\n\nThis fixes t5505 and t7810.\n\nSigned-off-by: Karsten Blees <blees@dcon.de>\nSigned-off-by: Erik Faye-Lund <kusmabite@gmail.com>\nSigned-off-by: Stepan Kasal <kasal@ucw.cz>\n---\n compat/mingw.c | 6 ++++++\n 1 file changed, 6 insertions(+)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex 6849815..1140a13 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -1927,6 +1927,12 @@ int xwcstoutf(char *utf, const wchar_t *wcs, size_t utflen)\n \treturn -1;\n }\n \n+/*\n+ * Disable MSVCRT command line wildcard expansion (__getmainargs called from\n+ * mingw startup code, see init.c in mingw runtime).\n+ */\n+int _CRT_glob = 0;\n+\n void mingw_startup()\n {\n \t/* copy executable name to argv[0] */\n-- \n2.0.0.9635.g0be03cb\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"243895","messageId":"1402479466-8500-6-git-send-email-kasal@ucw.cz","threadId":"36888","inReplyTo":"1402479466-8500-1-git-send-email-kasal@ucw.cz","subject":"[PATCH 5/7] Win32: Unicode arguments (outgoing)","fromName":"Stepan Kasal","fromEmail":"kasal@ucw.cz","sentAt":"2014-06-11T09:37:44Z","receivedAt":"2014-06-11T09:37:44Z","isPatch":true,"sender":{"key":"kasal@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/1481596?v=4"},"body":"From: Karsten Blees <blees@dcon.de>\nDate: Sun, 16 Jan 2011 18:27:53 +0100\n\nConvert command line arguments from UTF-8 to UTF-16 when creating other\nprocesses.\n\nSigned-off-by: Karsten Blees <blees@dcon.de>\nSigned-off-by: Stepan Kasal <kasal@ucw.cz>\n---\n compat/mingw.c | 18 ++++++++++++++----\n 1 file changed, 14 insertions(+), 4 deletions(-)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex 1140a13..8a7b047 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -831,9 +831,10 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **env,\n \t\t\t      const char *dir,\n \t\t\t      int prepend_cmd, int fhin, int fhout, int fherr)\n {\n-\tSTARTUPINFO si;\n+\tSTARTUPINFOW si;\n \tPROCESS_INFORMATION pi;\n \tstruct strbuf envblk, args;\n+\twchar_t wcmd[MAX_PATH], wdir[MAX_PATH], *wargs;\n \tunsigned flags;\n \tBOOL ret;\n \n@@ -869,6 +870,11 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **env,\n \tsi.hStdOutput = winansi_get_osfhandle(fhout);\n \tsi.hStdError = winansi_get_osfhandle(fherr);\n \n+\tif (xutftowcs_path(wcmd, cmd) < 0)\n+\t\treturn -1;\n+\tif (dir && xutftowcs_path(wdir, dir) < 0)\n+\t\treturn -1;\n+\n \t/* concatenate argv, quoting args as we go */\n \tstrbuf_init(&args, 0);\n \tif (prepend_cmd) {\n@@ -886,6 +892,10 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **env,\n \t\t\tfree(quoted);\n \t}\n \n+\twargs = xmalloc((2 * args.len + 1) * sizeof(wchar_t));\n+\txutftowcs(wargs, args.buf, 2 * args.len + 1);\n+\tstrbuf_release(&args);\n+\n \tif (env) {\n \t\tint count = 0;\n \t\tchar **e, **sorted_env;\n@@ -907,12 +917,12 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **env,\n \t}\n \n \tmemset(&pi, 0, sizeof(pi));\n-\tret = CreateProcess(cmd, args.buf, NULL, NULL, TRUE, flags,\n-\t\tenv ? envblk.buf : NULL, dir, &si, &pi);\n+\tret = CreateProcessW(wcmd, wargs, NULL, NULL, TRUE, flags,\n+\t\tenv ? envblk.buf : NULL, dir ? wdir : NULL, &si, &pi);\n \n \tif (env)\n \t\tstrbuf_release(&envblk);\n-\tstrbuf_release(&args);\n+\tfree(wargs);\n \n \tif (!ret) {\n \t\terrno = ENOENT;\n-- \n2.0.0.9635.g0be03cb\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"243889","messageId":"1402479466-8500-7-git-send-email-kasal@ucw.cz","threadId":"36888","inReplyTo":"1402479466-8500-1-git-send-email-kasal@ucw.cz","subject":"[PATCH 6/7] Win32: Unicode arguments (incoming)","fromName":"Stepan Kasal","fromEmail":"kasal@ucw.cz","sentAt":"2014-06-11T09:37:45Z","receivedAt":"2014-06-11T09:37:45Z","isPatch":true,"sender":{"key":"kasal@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/1481596?v=4"},"body":"From: Karsten Blees <blees@dcon.de>\nDate: Sun, 16 Jan 2011 18:28:27 +0100\n\nConvert command line arguments from UTF-16 to UTF-8 on startup.\n\nSigned-off-by: Karsten Blees <blees@dcon.de>\nSigned-off-by: Stepan Kasal <kasal@ucw.cz>\n---\n compat/mingw.c | 42 ++++++++++++++++++++++++++++++++++++++++--\n 1 file changed, 40 insertions(+), 2 deletions(-)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex 8a7b047..3baaa4d 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -1943,10 +1943,48 @@ int xwcstoutf(char *utf, const wchar_t *wcs, size_t utflen)\n  */\n int _CRT_glob = 0;\n \n+typedef struct {\n+\tint newmode;\n+} _startupinfo;\n+\n+extern int __wgetmainargs(int *argc, wchar_t ***argv, wchar_t ***env, int glob,\n+\t\t_startupinfo *si);\n+\n+static NORETURN void die_startup()\n+{\n+\tfputs(\"fatal: not enough memory for initialization\", stderr);\n+\texit(128);\n+}\n+\n void mingw_startup()\n {\n-\t/* copy executable name to argv[0] */\n-\t__argv[0] = xstrdup(_pgmptr);\n+\tint i, len, maxlen, argc;\n+\tchar *buffer;\n+\twchar_t **wenv, **wargv;\n+\t_startupinfo si;\n+\n+\t/* get wide char arguments and environment */\n+\tsi.newmode = 0;\n+\tif (__wgetmainargs(&argc, &wargv, &wenv, _CRT_glob, &si) < 0)\n+\t\tdie_startup();\n+\n+\t/* determine size of argv and environ conversion buffer */\n+\tmaxlen = wcslen(_wpgmptr);\n+\tfor (i = 1; i < argc; i++)\n+\t\tmaxlen = max(maxlen, wcslen(wargv[i]));\n+\n+\t/* allocate buffer (wchar_t encodes to max 3 UTF-8 bytes) */\n+\tmaxlen = 3 * maxlen + 1;\n+\tbuffer = xmalloc(maxlen);\n+\n+\t/* convert command line arguments and environment to UTF-8 */\n+\tlen = xwcstoutf(buffer, _wpgmptr, maxlen);\n+\t__argv[0] = xmemdupz(buffer, len);\n+\tfor (i = 1; i < argc; i++) {\n+\t\tlen = xwcstoutf(buffer, wargv[i], maxlen);\n+\t\t__argv[i] = xmemdupz(buffer, len);\n+\t}\n+\tfree(buffer);\n \n \t/* initialize critical section for waitpid pinfo_t list */\n \tInitializeCriticalSection(&pinfo_cs);\n-- \n2.0.0.9635.g0be03cb\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"243891","messageId":"1402479466-8500-8-git-send-email-kasal@ucw.cz","threadId":"36888","inReplyTo":"1402479466-8500-1-git-send-email-kasal@ucw.cz","subject":"[PATCH 7/7] Unicode file name support (gitk and git-gui)","fromName":"Stepan Kasal","fromEmail":"kasal@ucw.cz","sentAt":"2014-06-11T09:37:46Z","receivedAt":"2014-06-11T09:37:46Z","isPatch":true,"sender":{"key":"kasal@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/1481596?v=4"},"body":"From: Karsten Blees <blees@dcon.de>\nDate: Sat, 4 Feb 2012 21:54:36 +0100\n\nAssumes file names in git tree objects are UTF-8 encoded.\n\nOn most unix systems, the system encoding (and thus the TCL system\nencoding) will be UTF-8, so file names will be displayed correctly.\n\nOn Windows, it is impossible to set the system encoding to UTF-8. Changing\nthe TCL system encoding (via 'encoding system ...', e.g. in the startup\ncode) is explicitly discouraged by the TCL docs.\n\nChange gitk and git-gui functions dealing with file names to always convert\nfrom and to UTF-8.\n\nSigned-off-by: Karsten Blees <blees@dcon.de>\nSigned-off-by: Stepan Kasal <kasal@ucw.cz>\n---\n git-gui/git-gui.sh      | 11 +++++++----\n git-gui/lib/browser.tcl |  2 +-\n git-gui/lib/index.tcl   |  6 +++---\n gitk-git/gitk           | 15 ++++++++-------\n 4 files changed, 19 insertions(+), 15 deletions(-)\n\ndiff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh\nindex b186329..f9c942c 100755\n--- a/git-gui/git-gui.sh\n+++ b/git-gui/git-gui.sh\n@@ -548,6 +548,9 @@ proc git {args} {\n \n \t_trace_exec [concat $opt $cmdp $args]\n \tset result [eval exec $opt $cmdp $args]\n+\tif {[encoding system] != \"utf-8\"} {\n+\t\tset result [encoding convertfrom utf-8 [encoding convertto $result]]\n+\t}\n \tif {$::_trace} {\n \t\tputs stderr \"< $result\"\n \t}\n@@ -1104,7 +1107,7 @@ git-version proc _parse_config {arr_name args} {\n \t\t\t\t[list git_read config] \\\n \t\t\t\t$args \\\n \t\t\t\t[list --null --list]]\n-\t\t\tfconfigure $fd_rc -translation binary\n+\t\t\tfconfigure $fd_rc -translation binary -encoding utf-8\n \t\t\tset buf [read $fd_rc]\n \t\t\tclose $fd_rc\n \t\t}\n@@ -1682,7 +1685,7 @@ proc read_diff_index {fd after} {\n \t\tset i [split [string range $buf_rdi $c [expr {$z1 - 2}]] { }]\n \t\tset p [string range $buf_rdi $z1 [expr {$z2 - 1}]]\n \t\tmerge_state \\\n-\t\t\t[encoding convertfrom $p] \\\n+\t\t\t[encoding convertfrom utf-8 $p] \\\n \t\t\t[lindex $i 4]? \\\n \t\t\t[list [lindex $i 0] [lindex $i 2]] \\\n \t\t\t[list]\n@@ -1715,7 +1718,7 @@ proc read_diff_files {fd after} {\n \t\tset i [split [string range $buf_rdf $c [expr {$z1 - 2}]] { }]\n \t\tset p [string range $buf_rdf $z1 [expr {$z2 - 1}]]\n \t\tmerge_state \\\n-\t\t\t[encoding convertfrom $p] \\\n+\t\t\t[encoding convertfrom utf-8 $p] \\\n \t\t\t?[lindex $i 4] \\\n \t\t\t[list] \\\n \t\t\t[list [lindex $i 0] [lindex $i 2]]\n@@ -1738,7 +1741,7 @@ proc read_ls_others {fd after} {\n \tset pck [split $buf_rlo \"\\0\"]\n \tset buf_rlo [lindex $pck end]\n \tforeach p [lrange $pck 0 end-1] {\n-\t\tset p [encoding convertfrom $p]\n+\t\tset p [encoding convertfrom utf-8 $p]\n \t\tif {[string index $p end] eq {/}} {\n \t\t\tset p [string range $p 0 end-1]\n \t\t}\ndiff --git a/git-gui/lib/browser.tcl b/git-gui/lib/browser.tcl\nindex 0328338..555db89 100644\n--- a/git-gui/lib/browser.tcl\n+++ b/git-gui/lib/browser.tcl\n@@ -197,7 +197,7 @@ method _ls {tree_id {name {}}} {\n \t$w conf -state disabled\n \n \tset fd [git_read ls-tree -z $tree_id]\n-\tfconfigure $fd -blocking 0 -translation binary -encoding binary\n+\tfconfigure $fd -blocking 0 -translation binary -encoding utf-8\n \tfileevent $fd readable [cb _read $fd]\n }\n \ndiff --git a/git-gui/lib/index.tcl b/git-gui/lib/index.tcl\nindex 74a81a7..d10ffe9 100644\n--- a/git-gui/lib/index.tcl\n+++ b/git-gui/lib/index.tcl\n@@ -115,7 +115,7 @@ proc write_update_indexinfo {fd pathList totalCnt batch after} {\n \t\tset info [lindex $s 2]\n \t\tif {$info eq {}} continue\n \n-\t\tputs -nonewline $fd \"$info\\t[encoding convertto $path]\\0\"\n+\t\tputs -nonewline $fd \"$info\\t[encoding convertto utf-8 $path]\\0\"\n \t\tdisplay_file $path $new\n \t}\n \n@@ -186,7 +186,7 @@ proc write_update_index {fd pathList totalCnt batch after} {\n \t\t?M {set new M_}\n \t\t?? {continue}\n \t\t}\n-\t\tputs -nonewline $fd \"[encoding convertto $path]\\0\"\n+\t\tputs -nonewline $fd \"[encoding convertto utf-8 $path]\\0\"\n \t\tdisplay_file $path $new\n \t}\n \n@@ -247,7 +247,7 @@ proc write_checkout_index {fd pathList totalCnt batch after} {\n \t\t?M -\n \t\t?T -\n \t\t?D {\n-\t\t\tputs -nonewline $fd \"[encoding convertto $path]\\0\"\n+\t\t\tputs -nonewline $fd \"[encoding convertto utf-8 $path]\\0\"\n \t\t\tdisplay_file $path ?_\n \t\t}\n \t\t}\ndiff --git a/gitk-git/gitk b/gitk-git/gitk\nindex f6efaa6..0301608 100755\n--- a/gitk-git/gitk\n+++ b/gitk-git/gitk\n@@ -7529,7 +7529,7 @@ proc gettreeline {gtf id} {\n \tif {[string index $fname 0] eq \"\\\"\"} {\n \t    set fname [lindex $fname 0]\n \t}\n-\tset fname [encoding convertfrom $fname]\n+\tset fname [encoding convertfrom utf-8 $fname]\n \tlappend treefilelist($id) $fname\n     }\n     if {![eof $gtf]} {\n@@ -7791,7 +7791,7 @@ proc gettreediffline {gdtf ids} {\n \t    if {[string index $file 0] eq \"\\\"\"} {\n \t\tset file [lindex $file 0]\n \t    }\n-\t    set file [encoding convertfrom $file]\n+\t    set file [encoding convertfrom utf-8 $file]\n \t    if {$file ne [lindex $treediff end]} {\n \t\tlappend treediff $file\n \t\tlappend sublist $file\n@@ -7936,7 +7936,7 @@ proc makediffhdr {fname ids} {\n     global ctext curdiffstart treediffs diffencoding\n     global ctext_file_names jump_to_here targetline diffline\n \n-    set fname [encoding convertfrom $fname]\n+    set fname [encoding convertfrom utf-8 $fname]\n     set diffencoding [get_path_encoding $fname]\n     set i [lsearch -exact $treediffs($ids) $fname]\n     if {$i >= 0} {\n@@ -7993,7 +7993,7 @@ proc parseblobdiffline {ids line} {\n \n     if {![string compare -length 5 \"diff \" $line]} {\n \tif {![regexp {^diff (--cc|--git) } $line m type]} {\n-\t    set line [encoding convertfrom $line]\n+\t    set line [encoding convertfrom utf-8 $line]\n \t    $ctext insert end \"$line\\n\" hunksep\n \t    continue\n \t}\n@@ -8040,7 +8040,7 @@ proc parseblobdiffline {ids line} {\n \tmakediffhdr $fname $ids\n \n     } elseif {![string compare -length 16 \"* Unmerged path \" $line]} {\n-\tset fname [encoding convertfrom [string range $line 16 end]]\n+\tset fname [encoding convertfrom utf-8 [string range $line 16 end]]\n \t$ctext insert end \"\\n\"\n \tset curdiffstart [$ctext index \"end - 1c\"]\n \tlappend ctext_file_names $fname\n@@ -8095,7 +8095,7 @@ proc parseblobdiffline {ids line} {\n \t    if {[string index $fname 0] eq \"\\\"\"} {\n \t\tset fname [lindex $fname 0]\n \t    }\n-\t    set fname [encoding convertfrom $fname]\n+\t    set fname [encoding convertfrom utf-8 $fname]\n \t    set i [lsearch -exact $treediffs($ids) $fname]\n \t    if {$i >= 0} {\n \t\tsetinlist difffilestart $i $curdiffstart\n@@ -8114,6 +8114,7 @@ proc parseblobdiffline {ids line} {\n \t    set diffinhdr 0\n \t    return\n \t}\n+\tset line [encoding convertfrom utf-8 $line]\n \t$ctext insert end \"$line\\n\" filesep\n \n     } else {\n@@ -11902,7 +11903,7 @@ proc cache_gitattr {attr pathlist} {\n \t    foreach row [split $rlist \"\\n\"] {\n \t\tif {[regexp \"(.*): $attr: (.*)\" $row m path value]} {\n \t\t    if {[string index $path 0] eq \"\\\"\"} {\n-\t\t\tset path [encoding convertfrom [lindex $path 0]]\n+\t\t\tset path [encoding convertfrom utf-8 [lindex $path 0]]\n \t\t    }\n \t\t    set path_attr_cache($attr,$path) $value\n \t\t}\n-- \n2.0.0.9635.g0be03cb\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"244386","messageId":"53A0052C.6040604@gmail.com","threadId":"36888","inReplyTo":"1402479466-8500-1-git-send-email-kasal@ucw.cz","subject":"Re: [PATCH 0/7] Second part of msysgit/unicode","fromName":"Karsten Blees","fromEmail":"karsten.blees@gmail.com","sentAt":"2014-06-17T09:06:52Z","receivedAt":"2014-06-17T09:06:52Z","isPatch":true,"sender":{"key":"karsten.blees@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1111200?v=4"},"body":"Am 11.06.2014 11:37, schrieb Stepan Kasal:\n> This is the second part of the time-proven unicode suport branch from msysgit.\n> This batch is a collection of small independent changes, limited to mingw.c.\n> The only exception is the last patch: it changes gitk and git-gui.\n> \n\nI'm missing the other two \"Unicode file name\" patches (and \"Win32: fix detection\nof empty directories in is_dir_empty\", probably squashed). If gitk and git-gui\nexpect file names to be UTF-8, git.exe should do so as well, don't you think?\n\nOtherwise OK (and AFAICT, there's only environment stuff left).\n\n>   Win32: Unicode arguments (incoming)\n\nNote: This depends on \"MSVC: link dynamically to the CRT\", which was sent\nseparately (and is already in master - good).\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"244496","messageId":"20140618030507.GA3809@camelia.ucw.cz","threadId":"36888","inReplyTo":"53A0052C.6040604@gmail.com","subject":"Re: [PATCH 0/7] Second part of msysgit/unicode","fromName":"Stepan Kasal","fromEmail":"kasal@ucw.cz","sentAt":"2014-06-18T03:05:07Z","receivedAt":"2014-06-18T03:05:07Z","isPatch":true,"sender":{"key":"kasal@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/1481596?v=4"},"body":"Hello Karsten,\n\nOn Tue, Jun 17, 2014 at 11:06:52AM +0200, Karsten Blees wrote:\n> Am 11.06.2014 11:37, schrieb Stepan Kasal:\n> > This is the second part of the time-proven unicode suport branch from msysgit.\n> > This batch is a collection of small independent changes, limited to mingw.c.\n> > The only exception is the last patch: it changes gitk and git-gui.\n> \n> I'm missing the other two \"Unicode file name\" patches (and \"Win32: fix detection\n\nindeed.  I noticed that after sending the plan quoted above.\nLuckily, the gitk/git-gui patch was not accepted and has to be\nresubmitted.\n\nSo the plan for future submissions is:\n\n1) two \"Unicode file name\" patches (with \"fix... is_dir_empty\"\nsquashed)\n2) the environament patches from your unicode branch (several\npatches)\n3) \"color term\" (and env. var. TERM); updated according to your\ninstructions, thus sent separately after the series\n4) resubmit gitk / git-gui (have separate maintainers)\n\nThis is work in progress, I suppose to mail 1) and 2) in a few days.\n\nStepan\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"244545","messageId":"xmqq7g4ejf6y.fsf@gitster.dls.corp.google.com","threadId":"36888","inReplyTo":"20140618030507.GA3809@camelia.ucw.cz","subject":"Re: [PATCH 0/7] Second part of msysgit/unicode","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-06-18T17:33:09Z","receivedAt":"2014-06-18T17:33:09Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stepan Kasal <kasal@ucw.cz> writes:\n\n> Hello Karsten,\n>\n> On Tue, Jun 17, 2014 at 11:06:52AM +0200, Karsten Blees wrote:\n>> Am 11.06.2014 11:37, schrieb Stepan Kasal:\n>> > This is the second part of the time-proven unicode suport branch from msysgit.\n>> > This batch is a collection of small independent changes, limited to mingw.c.\n>> > The only exception is the last patch: it changes gitk and git-gui.\n>> \n>> I'm missing the other two \"Unicode file name\" patches (and \"Win32: fix detection\n>\n> indeed.  I noticed that after sending the plan quoted above.\n> Luckily, the gitk/git-gui patch was not accepted and has to be\n> resubmitted.\n>\n> So the plan for future submissions is:\n>\n> 1) two \"Unicode file name\" patches (with \"fix... is_dir_empty\"\n> squashed)\n> 2) the environament patches from your unicode branch (several\n> patches)\n> 3) \"color term\" (and env. var. TERM); updated according to your\n> instructions, thus sent separately after the series\n> 4) resubmit gitk / git-gui (have separate maintainers)\n>\n> This is work in progress, I suppose to mail 1) and 2) in a few days.\n>\n> Stepan\n\nIn the meantime, are Windows folks happy with the four topics queued\non 'pu' so far?  I would like to start moving them down to 'next'\nand to 'master' soonish.\n\nThey consist of these individual patches:\n\n    $ git shortlog ^master \\\n      sk/mingw-dirent \\\n      sk/mingw-main \\\n      sk/mingw-uni-console \\\n      sk/mingw-unicode-spawn-args\n    Johannes Schindelin (1):\n          Win32: let mingw_execve() return an int\n\n    Karsten Blees (18):\n          Win32 dirent: remove unused dirent.d_ino member\n          Win32 dirent: remove unused dirent.d_reclen member\n          Win32 dirent: change FILENAME_MAX to MAX_PATH\n          Win32 dirent: clarify #include directives\n          Win32 dirent: improve dirent implementation\n          Win32: move main macro to a function\n          Win32: support Unicode console output\n          Win32: detect console streams more reliably\n          Win32: warn if the console font doesn't support Unicode\n          Win32: add Unicode conversion functions\n          Win32: Thread-safe windows console output\n          Win32: fix broken pipe detection\n          Win32: reliably detect console pipe handles\n          Win32: simplify internal mingw_spawn* APIs\n          Win32: fix potential multi-threading issue\n          MinGW: disable CRT command line globbing\n          Win32: Unicode arguments (outgoing)\n          Win32: Unicode arguments (incoming)\n\n    Stepan Kasal (1):\n          mingw: avoid const warning\n\nThanks.\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"244601","messageId":"53A20610.80500@kdbg.org","threadId":"36888","inReplyTo":"xmqq7g4ejf6y.fsf@gitster.dls.corp.google.com","subject":"Re: Re: [PATCH 0/7] Second part of msysgit/unicode","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2014-06-18T21:35:12Z","receivedAt":"2014-06-18T21:35:12Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 18.06.2014 19:33, schrieb Junio C Hamano:\n> In the meantime, are Windows folks happy with the four topics queued\n> on 'pu' so far?  I would like to start moving them down to 'next'\n> and to 'master' soonish.\n> \n> They consist of these individual patches:\n> \n>     $ git shortlog ^master \\\n>       sk/mingw-dirent \\\n>       sk/mingw-main \\\n>       sk/mingw-uni-console \\\n>       sk/mingw-unicode-spawn-args\n\nTopic sk/test-cmp-bin revealed a new breakage in t5000-tar-tree,\nspecifically, the penultimate test \"remote tar.gz is allowed by\ndefault\". I have yet to find out what it is (I suspect a LF-CRLF\nconversion issue) and whether it is in connection with one of these topics.\n\nI haven't had a chance to test the topics in the field. In particular, I\nhave a few files with Shift-JIS content (but ASCII file names), and I\nwould like to see how well I fare with the unicode topics in this situation.\n\n-- Hannes\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"}]}