]> git.ipfire.org Git - thirdparty/git.git/commitdiff
compat/mingw: implement a native locate_in_PATH()
authorMatthias Aßhauer <mha1993@live.de>
Fri, 4 Aug 2023 04:08:43 +0000 (04:08 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 4 Aug 2023 04:21:10 +0000 (21:21 -0700)
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 <Louis.Strous@intellimagic.com>
Signed-off-by: Matthias Aßhauer <mha1993@live.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
compat/mingw.c
compat/mingw.h

index d06cdc6254fbc34eabcd1130c08ae6b8f1fcae01..bc3669d2986d8898a46359c1a3e8068fb498fd7c 100644 (file)
@@ -1347,6 +1347,11 @@ static char *path_lookup(const char *cmd, int exe_only)
        return prog;
 }
 
+char *mingw_locate_in_PATH(const char *cmd)
+{
+       return path_lookup(cmd, 0);
+}
+
 static const wchar_t *wcschrnul(const wchar_t *s, wchar_t c)
 {
        while (*s && *s != c)
index 209cf7cebadd1746c8b79e1105bac103b8a72910..b526220596582930a26809131cf64ef690241125 100644 (file)
@@ -175,6 +175,9 @@ pid_t waitpid(pid_t pid, int *status, int options);
 #define kill mingw_kill
 int mingw_kill(pid_t pid, int sig);
 
+#define locate_in_PATH mingw_locate_in_PATH
+char *mingw_locate_in_PATH(const char *cmd);
+
 #ifndef NO_OPENSSL
 #include <openssl/ssl.h>
 static inline int mingw_SSL_set_fd(SSL *ssl, int fd)