Skip to content

Commit 2bf46a9

Browse files
rimrulgitster
authored andcommitted
compat/mingw: implement a native locate_in_PATH()
since 5e1f28d (bisect--helper: reimplement `bisect_visualize()` shell function in C, 2021-09-13) `git bisect visualize` uses exists_in_PATH() to check wether it should call `gitk`, but exists_in_PATH() relies on locate_in_PATH() which currently only understands POSIX-ish PATH variables (a list of paths, separated by colons) on native Windows executables we encounter Windows PATH variables (a list of paths that often contain drive letters (and thus colons), separated by semicolons). Luckily we do already have a function that can lookup executables on windows PATHs: path_lookup(). Implement a small replacement for the existing locate_in_PATH() based on path_lookup(). Reported-by: Louis Strous <[email protected]> Signed-off-by: Matthias Aßhauer <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bb532b5 commit 2bf46a9

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

compat/mingw.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,6 +1347,11 @@ static char *path_lookup(const char *cmd, int exe_only)
13471347
return prog;
13481348
}
13491349

1350+
char *mingw_locate_in_PATH(const char *cmd)
1351+
{
1352+
return path_lookup(cmd, 0);
1353+
}
1354+
13501355
static const wchar_t *wcschrnul(const wchar_t *s, wchar_t c)
13511356
{
13521357
while (*s && *s != c)

compat/mingw.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ pid_t waitpid(pid_t pid, int *status, int options);
175175
#define kill mingw_kill
176176
int mingw_kill(pid_t pid, int sig);
177177

178+
#define locate_in_PATH mingw_locate_in_PATH
179+
char *mingw_locate_in_PATH(const char *cmd);
180+
178181
#ifndef NO_OPENSSL
179182
#include <openssl/ssl.h>
180183
static inline int mingw_SSL_set_fd(SSL *ssl, int fd)

0 commit comments

Comments
 (0)