mirror of
https://github.com/git/git.git
synced 2024-11-27 20:14:30 +08:00
Merge branch 'ak/run-command-on-cygwin-fix'
Utitiles run via the run_command() API were not spawned correctly on Cygwin, when the paths to them are given as a full path with backslashes. * ak/run-command-on-cygwin-fix: run-command: trigger PATH lookup properly on Cygwin
This commit is contained in:
commit
d01b722b7a
@ -20,6 +20,17 @@ static inline char *win32_find_last_dir_sep(const char *path)
|
||||
return ret;
|
||||
}
|
||||
#define find_last_dir_sep win32_find_last_dir_sep
|
||||
static inline int win32_has_dir_sep(const char *path)
|
||||
{
|
||||
/*
|
||||
* See how long the non-separator part of the given path is, and
|
||||
* if and only if it covers the whole path (i.e. path[len] is NUL),
|
||||
* there is no separator in the path---otherwise there is a separator.
|
||||
*/
|
||||
size_t len = strcspn(path, "/\\");
|
||||
return !!path[len];
|
||||
}
|
||||
#define has_dir_sep(path) win32_has_dir_sep(path)
|
||||
int win32_offset_1st_component(const char *path);
|
||||
#define offset_1st_component win32_offset_1st_component
|
||||
|
||||
|
@ -389,6 +389,14 @@ static inline char *git_find_last_dir_sep(const char *path)
|
||||
#define find_last_dir_sep git_find_last_dir_sep
|
||||
#endif
|
||||
|
||||
#ifndef has_dir_sep
|
||||
static inline int git_has_dir_sep(const char *path)
|
||||
{
|
||||
return !!strchr(path, '/');
|
||||
}
|
||||
#define has_dir_sep(path) git_has_dir_sep(path)
|
||||
#endif
|
||||
|
||||
#ifndef query_user_email
|
||||
#define query_user_email() NULL
|
||||
#endif
|
||||
|
@ -421,12 +421,12 @@ static int prepare_cmd(struct argv_array *out, const struct child_process *cmd)
|
||||
}
|
||||
|
||||
/*
|
||||
* If there are no '/' characters in the command then perform a path
|
||||
* lookup and use the resolved path as the command to exec. If there
|
||||
* are '/' characters, we have exec attempt to invoke the command
|
||||
* directly.
|
||||
* If there are no dir separator characters in the command then perform
|
||||
* a path lookup and use the resolved path as the command to exec. If
|
||||
* there are dir separator characters, we have exec attempt to invoke
|
||||
* the command directly.
|
||||
*/
|
||||
if (!strchr(out->argv[1], '/')) {
|
||||
if (!has_dir_sep(out->argv[1])) {
|
||||
char *program = locate_in_PATH(out->argv[1]);
|
||||
if (program) {
|
||||
free((char *)out->argv[1]);
|
||||
|
Loading…
Reference in New Issue
Block a user