2007-04-29 14:38:52 +08:00
|
|
|
#ifndef GIT_EXEC_CMD_H
|
|
|
|
#define GIT_EXEC_CMD_H
|
2006-01-11 10:12:17 +08:00
|
|
|
|
prepare_{git,shell}_cmd: use argv_array
These functions transform an existing argv into one suitable
for exec-ing or spawning via git or a shell. We can use an
argv_array in each to avoid dealing with manual counting and
allocation.
This also makes the memory allocation more clear and fixes
some leaks. In prepare_shell_cmd, we would sometimes
allocate a new string with "$@" in it and sometimes not,
meaning the caller could not correctly free it. On the
non-Windows side, we are in a child process which will
exec() or exit() immediately, so the leak isn't a big deal.
On Windows, though, we use spawn() from the parent process,
and leak a string for each shell command we run. On top of
that, the Windows code did not free the allocated argv array
at all (but does for the prepare_git_cmd case!).
By switching both of these functions to write into an
argv_array, we can consistently free the result as
appropriate.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-02-23 06:44:39 +08:00
|
|
|
struct argv_array;
|
|
|
|
|
2018-04-10 23:05:44 +08:00
|
|
|
extern void git_set_exec_path(const char *exec_path);
|
|
|
|
extern void git_resolve_executable_dir(const char *path);
|
2009-01-18 20:00:10 +08:00
|
|
|
extern const char *git_exec_path(void);
|
2008-07-22 03:19:52 +08:00
|
|
|
extern void setup_path(void);
|
prepare_{git,shell}_cmd: use argv_array
These functions transform an existing argv into one suitable
for exec-ing or spawning via git or a shell. We can use an
argv_array in each to avoid dealing with manual counting and
allocation.
This also makes the memory allocation more clear and fixes
some leaks. In prepare_shell_cmd, we would sometimes
allocate a new string with "$@" in it and sometimes not,
meaning the caller could not correctly free it. On the
non-Windows side, we are in a child process which will
exec() or exit() immediately, so the leak isn't a big deal.
On Windows, though, we use spawn() from the parent process,
and leak a string for each shell command we run. On top of
that, the Windows code did not free the allocated argv array
at all (but does for the prepare_git_cmd case!).
By switching both of these functions to write into an
argv_array, we can consistently free the result as
appropriate.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-02-23 06:44:39 +08:00
|
|
|
extern const char **prepare_git_cmd(struct argv_array *out, const char **argv);
|
2006-03-05 18:47:29 +08:00
|
|
|
extern int execv_git_cmd(const char **argv); /* NULL terminated */
|
2013-07-19 04:02:12 +08:00
|
|
|
LAST_ARG_MUST_BE_NULL
|
2006-03-05 18:47:29 +08:00
|
|
|
extern int execl_git_cmd(const char *cmd, ...);
|
2014-11-25 03:33:54 +08:00
|
|
|
extern char *system_path(const char *path);
|
2006-01-11 10:12:17 +08:00
|
|
|
|
2007-04-29 14:38:52 +08:00
|
|
|
#endif /* GIT_EXEC_CMD_H */
|