git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] exec_git_cmd: fix executing commands if path contains spaces

From
Steffen Prohaska <prohaska@zib.de>
Date
Oct 9, 2007, 21:39 UTC
Message-ID
<11919659771056-git-send-email-prohaska@zib.de>
In-Reply-To
<470BB44B.3030500@viscovery.net>

This patch fixed executing of non-builtins if installation dir contains spaces. That is 'git var' works now.

The original patch is by Johannes Sixt <j.sixt@viscovery.net>.
Signed-off-by: Steffen Prohaska <prohaska@zib.de>
---
 compat/mingw.c    |    2 +-
 exec_cmd.c        |    2 +-
 git-compat-util.h |    1 +
 3 files changed, 3 insertions(+), 2 deletions(-)

Ok, this is what I created from the quick-fix. It works for me in msysgit.

Should the patch be polished that it can be applied to git.git or will we only apply it to 4msysgit?

If it should be polished, what would be the right way? ifdef in exec_cmd.c?

	Steffen
diff --git a/compat/mingw.c b/compat/mingw.c
index 6632192..0dd0cb0 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -196,7 +196,7 @@ void openlog(const char *ident, int option, int facility)
 {
 }
 
-static const char *quote_arg(const char *arg)
+const char *quote_arg(const char *arg)
 {
 	/* count chars to quote */
 	int len = 0, n = 0;
diff --git a/exec_cmd.c b/exec_cmd.c
index 2a8e48b..4c7c7ca 100644
--- a/exec_cmd.c
+++ b/exec_cmd.c
@@ -132,7 +132,7 @@ int execv_git_cmd(const char **argv)
 		 */
 
 		tmp = argv[0];
-		argv[0] = git_command;
+		argv[0] = quote_arg(git_command);
 
 		trace_argv_printf(argv, -1, "trace: exec:");
 
diff --git a/git-compat-util.h b/git-compat-util.h
index ba5a1a1..5276221 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -482,6 +482,7 @@ int mingw_socket(int domain, int type, int protocol);
 #define fsync(x) 0
 
 extern void quote_argv(const char **dst, const char **src);
+extern const char *quote_arg(const char *arg);
 extern const char *parse_interpreter(const char *cmd);
 
 extern __attribute__((noreturn)) int git_exit(int code);
-- 
1.5.3.mingw.1.13.g70ed-dirty
Previous: Linus TorvaldsNext: Johannes Sixt
Message 15 of 17 in “Merge problems with git-mingw”
  1. Peter KarlssonOct 8, 2007
  2. Lars HjemliOct 8, 2007
  3. Peter KarlssonOct 8, 2007
  4. Lars HjemliOct 8, 2007
  5. Peter KarlssonOct 8, 2007
  6. Lars HjemliOct 8, 2007
  7. Johannes SixtOct 9, 2007
  8. Peter KarlssonOct 9, 2007
  9. Johannes SixtOct 9, 2007
  10. Peter KarlssonOct 9, 2007
  11. Johannes SixtOct 9, 2007
  12. Steffen ProhaskaOct 9, 2007
  13. Johannes SixtOct 9, 2007
  14. Linus TorvaldsOct 9, 2007
  15. exec_git_cmd: fix executing commands if path contains spacesSteffen Prohaska, Oct 9, 2007
  16. Johannes SixtOct 10, 2007
  17. Fix invocation of external git commands with arguments with spaces.Johannes Sixt, Oct 10, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.