From 701b8d20ea05dee31965ab6647fdee041271da1d Mon Sep 17 00:00:00 2001 From: Heiko Voigt Date: Thu, 4 Feb 2010 22:12:34 +0100 Subject: [PATCH] msys: Patches to quote paths for non msys programs This enables calling git with wildcards from bash without having them expanded by neither bash nor the mingw layer. See the patches for more information. Signed-off-by: Heiko Voigt Signed-off-by: Johannes Schindelin --- ...-processes-combine-for-loops-and-resolve-.patch | 33 ++++++++++++++ ...-for-non-msys-programs-that-contain-wildc.patch | 51 ++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 src/rt/patches/0009-spawning-of-processes-combine-for-loops-and-resolve-.patch create mode 100644 src/rt/patches/0010-quote-paths-for-non-msys-programs-that-contain-wildc.patch diff --git a/src/rt/patches/0009-spawning-of-processes-combine-for-loops-and-resolve-.patch b/src/rt/patches/0009-spawning-of-processes-combine-for-loops-and-resolve-.patch new file mode 100644 index 00000000..d035b9d6 --- /dev/null +++ b/src/rt/patches/0009-spawning-of-processes-combine-for-loops-and-resolve-.patch @@ -0,0 +1,33 @@ +From 16490ed6f8eb761f5b80db6aebed6d805e48f57c Mon Sep 17 00:00:00 2001 +From: Heiko Voigt +Date: Wed, 3 Feb 2010 19:46:42 +0100 +Subject: [PATCH] spawning of processes: combine for loops and resolve fixme + +This enables easier handling of quoting the arguments. Additionally we +can get rid of the FIXME comment in the source. + +Signed-off-by: Heiko Voigt +--- + msys/rt/src/winsup/cygwin/spawn.cc | 6 +----- + 1 files changed, 1 insertions(+), 5 deletions(-) + +diff --git a/msys/rt/src/winsup/cygwin/spawn.cc b/msys/rt/src/winsup/cygwin/spawn.cc +index e7278e6..108b2f1 100644 +--- a/msys/rt/src/winsup/cygwin/spawn.cc ++++ b/msys/rt/src/winsup/cygwin/spawn.cc +@@ -515,11 +515,7 @@ spawn_guts (HANDLE hToken, const char * prog_arg, const char *const *argv, + debug_printf("newargv[%d] = %s", i, newargv[i]); + newargv.replace (i, tmpbuf); + free (tmpbuf); +- } +- FIXME; // Is the below loop necessary? +- // Well at least combine the above with it. +- for (int i = 0; i < newargv.argc; i++) +- { ++ + char *p = NULL; // Temporary use pointer. + const char *a; // Pointer to newargv element. + +-- +1.6.5.1.msysgit.1.12.gf4ccd + diff --git a/src/rt/patches/0010-quote-paths-for-non-msys-programs-that-contain-wildc.patch b/src/rt/patches/0010-quote-paths-for-non-msys-programs-that-contain-wildc.patch new file mode 100644 index 00000000..fbe7d1ca --- /dev/null +++ b/src/rt/patches/0010-quote-paths-for-non-msys-programs-that-contain-wildc.patch @@ -0,0 +1,51 @@ +From ca92234f3b5d3d0d54e0ba141cebdcfeebae11d9 Mon Sep 17 00:00:00 2001 +From: Heiko Voigt +Date: Wed, 3 Feb 2010 22:16:56 +0100 +Subject: [PATCH] quote paths for non msys programs that contain wildcards + +Native windows programs expect to receive quotes in their arguments. +Unlike in the Unix world where they are stripped by the shell. + +We are dealing with a thin mingw layer here that makes windows +commandline parsing behave like on Unix seen from inside of the program. +A native Windows program is expected to do wildcard expansion on its +own. Thus mingw automatically adds a layer that does this to every +program compiled (e.g. git). + +Problems occur when starting git with a wildcard from bash: + + git log -- "*" + +Bash then strips the "" and passes * to the lower layer like its done on +Unix. This is then given to the execution of the program, but because of +the wildcard expansion layer it would currently expand * before its +given to argv[]. Thats why we need to readd "" to all arguments +containing windows wildcards before calling a native program for all +arguments containing Windows wildcards. + +Signed-off-by: Heiko Voigt +--- + msys/rt/src/winsup/cygwin/spawn.cc | 7 ++++++- + 1 files changed, 6 insertions(+), 1 deletions(-) + +diff --git a/msys/rt/src/winsup/cygwin/spawn.cc b/msys/rt/src/winsup/cygwin/spawn.cc +index 108b2f1..342159f 100644 +--- a/msys/rt/src/winsup/cygwin/spawn.cc ++++ b/msys/rt/src/winsup/cygwin/spawn.cc +@@ -528,7 +528,12 @@ spawn_guts (HANDLE hToken, const char * prog_arg, const char *const *argv, + a = i ? newargv[i] : (char *) real_path; + HMMM(a); + int len = strlen (a); +- if (len != 0 && !strpbrk (a, " \t\n\r\"")) ++ /* surround paths that contain wildcards or special characters ++ * with quotes (") because they would have been expanded by ++ * bash already and a native Windows program expects its ++ * arguments not to be expanded by the shell unlike in the ++ * Unix world. */ ++ if (len != 0 && !strpbrk (a, " \t\n\r\"*?")) + one_line.add (a, len); + else + { +-- +1.6.5.1.msysgit.1.12.gf4ccd + -- 2.11.4.GIT