git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 2/3] compat/mingw: implement a native locate_in_PATH()

From
Matthias Aßhauer via GitGitGadget <gitgitgadget@gmail.com>
Date
Aug 4, 2023, 04:08 UTC
Message-ID
<8b8c8c3f70a25f198335e36dfd501ffcb9d411c3.1691122124.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.1560.v2.git.1691122124.gitgitgadget@gmail.com>
From: =?UTF-8?q?Matthias=20A=C3=9Fhauer?= <mha1993@live.de>
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>
---
 compat/mingw.c | 5 +++++
 compat/mingw.h | 3 +++
 2 files changed, 8 insertions(+)
diff --git a/compat/mingw.c b/compat/mingw.c
index d06cdc6254f..bc3669d2986 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -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)
diff --git a/compat/mingw.h b/compat/mingw.h
index 209cf7cebad..b5262205965 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -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)
-- 
gitgitgadget
Previous: Eric SunshineNext: Junio C Hamano
Message 22 of 23 in “git bisect visualize: find gitk on Windows again”
  1. 0/3 git bisect visualize: find gitk on Windows againMatthias Aßhauer via GitGitGadget, Aug 3, 2023
  2. 1/3 compat: make path_lookup() available outside mingw.cMatthias Aßhauer via GitGitGadget, Aug 3, 2023
  3. 3/3 docs: update when `git bisect visualize` uses `gitk`Matthias Aßhauer via GitGitGadget, Aug 3, 2023
  4. Junio C HamanoAug 3, 2023
  5. 2/3 run-command: teach locate_in_PATH about WindowsMatthias Aßhauer via GitGitGadget, Aug 3, 2023
  6. Junio C HamanoAug 3, 2023
  7. Junio C HamanoAug 3, 2023
  8. Junio C HamanoAug 3, 2023
  9. Matthias AßhauerAug 3, 2023
  10. Junio C HamanoAug 3, 2023
  11. 0/3 git bisect visualize: find gitk on Windows againMatthias Aßhauer via GitGitGadget, Aug 4, 2023
  12. 1/3 run-command: conditionally define locate_in_PATH()Matthias Aßhauer via GitGitGadget, Aug 4, 2023
  13. Junio C HamanoAug 4, 2023
  14. Matthias AßhauerAug 4, 2023
  15. Junio C HamanoAug 4, 2023
  16. 3/3 docs: update when `git bisect visualize` uses `gitk`Matthias Aßhauer via GitGitGadget, Aug 4, 2023
  17. Junio C HamanoAug 4, 2023
  18. Eric SunshineAug 4, 2023
  19. Matthias AßhauerAug 4, 2023
  20. Junio C HamanoAug 4, 2023
  21. Eric SunshineAug 4, 2023
  22. 2/3 compat/mingw: implement a native locate_in_PATH()Matthias Aßhauer via GitGitGadget, Aug 4, 2023
  23. Junio C HamanoAug 4, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.