Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Refactor, adding prepare_git_cmd(const char **argv)

prepare_git_cmd(const char **argv) adds a first entry "git" to
the array argv.  The new array is allocated on the heap.  It's
the caller's responsibility to release it with free().  The code
was already present in execv_git_cmd() but could not be used from
outside.  Now it can also be called for preparing the command list
in the MinGW codepath in run-command.c.

Signed-off-by: Steffen Prohaska <>
Signed-off-by: Junio C Hamano <>
  • Loading branch information...
commit 4933e5ebdefdb88841275132ef358e6649963751 1 parent d276189
@sprohaska sprohaska authored gitster committed
Showing with 7 additions and 1 deletion.
  1. +6 −1 exec_cmd.c
  2. +1 −0  exec_cmd.h
7 exec_cmd.c
@@ -78,7 +78,7 @@ void setup_path(void)
-int execv_git_cmd(const char **argv)
+const char **prepare_git_cmd(const char **argv)
int argc;
const char **nargv;
@@ -91,6 +91,11 @@ int execv_git_cmd(const char **argv)
for (argc = 0; argv[argc]; argc++)
nargv[argc + 1] = argv[argc];
nargv[argc + 1] = NULL;
+ return nargv;
+int execv_git_cmd(const char **argv) {
+ const char **nargv = prepare_git_cmd(argv);
trace_argv_printf(nargv, "trace: exec:");
/* execvp() can only ever return if it fails */
1  exec_cmd.h
@@ -5,6 +5,7 @@ extern void git_set_argv_exec_path(const char *exec_path);
extern void git_set_argv0_path(const char *path);
extern const char* git_exec_path(void);
extern void setup_path(void);
+extern const char **prepare_git_cmd(const char **argv);
extern int execv_git_cmd(const char **argv); /* NULL terminated */
extern int execl_git_cmd(const char *cmd, ...);
extern const char *system_path(const char *path);
Please sign in to comment.
Something went wrong with that request. Please try again.