git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Matthias Aßhauer via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: "Louis Strous" <Louis.Strous@intellimagic.com>,
	"Pranit Bauva" <pranit.bauva@gmail.com>,
	"Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
	"Denton Liu" <liu.denton@gmail.com>,
	"Tanushree Tumane" <tanushreetumane@gmail.com>,
	"Jeff Hostetler" <jeffhost@microsoft.com>,
	"Miriam Rubio" <mirucam@gmail.com>,
	"Junio C Hamano" <gitster@pobox.com>,
	"Matthias Aßhauer" <mha1993@live.de>,
	"Matthias Aßhauer" <mha1993@live.de>
Subject: [PATCH 1/3] compat: make path_lookup() available outside mingw.c
Date: Thu, 03 Aug 2023 10:28:16 +0000	[thread overview]
Message-ID: <6ed968e128897ad75fb09a69395ee3571bb40677.1691058498.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1560.git.1691058498.gitgitgadget@gmail.com>

From: =?UTF-8?q?Matthias=20A=C3=9Fhauer?= <mha1993@live.de>

Rename it to mingw_path_lookup() to avoid leading future contributors
to believe this would be portable.

This is in preparation for a patch to teach locate_in_PATH() and
exists_in_PATH() in run-command.c to work on windows.

Signed-off-by: Matthias Aßhauer <mha1993@live.de>
---
 compat/mingw.c | 20 ++++++++------------
 compat/mingw.h |  6 ++++++
 2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/compat/mingw.c b/compat/mingw.c
index d06cdc6254f..5d3368b1705 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -1316,11 +1316,7 @@ static char *lookup_prog(const char *dir, int dirlen, const char *cmd,
 	return NULL;
 }
 
-/*
- * Determines the absolute path of cmd using the split path in path.
- * If cmd contains a slash or backslash, no lookup is performed.
- */
-static char *path_lookup(const char *cmd, int exe_only)
+char *mingw_path_lookup(const char *cmd, int exe_only)
 {
 	const char *path;
 	char *prog = NULL;
@@ -1515,7 +1511,7 @@ static int is_msys2_sh(const char *cmd)
 		if (ret >= 0)
 			return ret;
 
-		p = path_lookup(cmd, 0);
+		p = mingw_path_lookup(cmd, 0);
 		if (!p)
 			ret = 0;
 		else {
@@ -1533,7 +1529,7 @@ static int is_msys2_sh(const char *cmd)
 		static char *sh;
 
 		if (!sh)
-			sh = path_lookup("sh", 0);
+			sh = mingw_path_lookup("sh", 0);
 
 		return !fspathcmp(cmd, sh);
 	}
@@ -1646,7 +1642,7 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
 
 	strace_env = getenv("GIT_STRACE_COMMANDS");
 	if (strace_env) {
-		char *p = path_lookup("strace.exe", 1);
+		char *p = mingw_path_lookup("strace.exe", 1);
 		if (!p)
 			return error("strace not found!");
 		if (xutftowcs_path(wcmd, p) < 0) {
@@ -1801,7 +1797,7 @@ pid_t mingw_spawnvpe(const char *cmd, const char **argv, char **deltaenv,
 		     int fhin, int fhout, int fherr)
 {
 	pid_t pid;
-	char *prog = path_lookup(cmd, 0);
+	char *prog = mingw_path_lookup(cmd, 0);
 
 	if (!prog) {
 		errno = ENOENT;
@@ -1812,7 +1808,7 @@ pid_t mingw_spawnvpe(const char *cmd, const char **argv, char **deltaenv,
 
 		if (interpr) {
 			const char *argv0 = argv[0];
-			char *iprog = path_lookup(interpr, 1);
+			char *iprog = mingw_path_lookup(interpr, 1);
 			argv[0] = prog;
 			if (!iprog) {
 				errno = ENOENT;
@@ -1841,7 +1837,7 @@ static int try_shell_exec(const char *cmd, char *const *argv)
 
 	if (!interpr)
 		return 0;
-	prog = path_lookup(interpr, 1);
+	prog = mingw_path_lookup(interpr, 1);
 	if (prog) {
 		int exec_id;
 		int argc = 0;
@@ -1890,7 +1886,7 @@ int mingw_execv(const char *cmd, char *const *argv)
 
 int mingw_execvp(const char *cmd, char *const *argv)
 {
-	char *prog = path_lookup(cmd, 0);
+	char *prog = mingw_path_lookup(cmd, 0);
 
 	if (prog) {
 		mingw_execv(prog, argv);
diff --git a/compat/mingw.h b/compat/mingw.h
index 209cf7cebad..af1ff4be320 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -626,3 +626,9 @@ void open_in_gdb(void);
  * Used by Pthread API implementation for Windows
  */
 int err_win_to_posix(DWORD winerr);
+
+/*
+ * Determines the absolute path of cmd using the split path in path.
+ * If cmd contains a slash or backslash, no lookup is performed.
+ */
+char *mingw_path_lookup(const char *cmd, int exe_only);
-- 
gitgitgadget


  reply	other threads:[~2023-08-03 10:28 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-03 10:28 [PATCH 0/3] git bisect visualize: find gitk on Windows again Matthias Aßhauer via GitGitGadget
2023-08-03 10:28 ` Matthias Aßhauer via GitGitGadget [this message]
2023-08-03 10:28 ` [PATCH 2/3] run-command: teach locate_in_PATH about Windows Matthias Aßhauer via GitGitGadget
2023-08-03 16:13   ` Junio C Hamano
2023-08-03 10:28 ` [PATCH 3/3] docs: update when `git bisect visualize` uses `gitk` Matthias Aßhauer via GitGitGadget
2023-08-03 16:21   ` Junio C Hamano
2023-08-03 16:00 ` [PATCH 0/3] git bisect visualize: find gitk on Windows again Junio C Hamano
2023-08-03 18:50   ` Junio C Hamano
2023-08-03 19:03     ` Matthias Aßhauer
2023-08-03 19:56       ` Junio C Hamano
2023-08-04  4:08 ` [PATCH v2 " Matthias Aßhauer via GitGitGadget
2023-08-04  4:08   ` [PATCH v2 1/3] run-command: conditionally define locate_in_PATH() Matthias Aßhauer via GitGitGadget
2023-08-04  4:23     ` Junio C Hamano
2023-08-04  5:27       ` Matthias Aßhauer
2023-08-04 16:44         ` Junio C Hamano
2023-08-04  4:08   ` [PATCH v2 2/3] compat/mingw: implement a native locate_in_PATH() Matthias Aßhauer via GitGitGadget
2023-08-04  4:23     ` Junio C Hamano
2023-08-04  4:08   ` [PATCH v2 3/3] docs: update when `git bisect visualize` uses `gitk` Matthias Aßhauer via GitGitGadget
2023-08-04  4:32     ` Junio C Hamano
2023-08-04  5:27     ` Eric Sunshine
2023-08-04  5:54       ` Matthias Aßhauer
2023-08-04 16:45         ` Junio C Hamano
2023-08-04 16:57           ` Eric Sunshine

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6ed968e128897ad75fb09a69395ee3571bb40677.1691058498.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=Louis.Strous@intellimagic.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jeffhost@microsoft.com \
    --cc=liu.denton@gmail.com \
    --cc=mha1993@live.de \
    --cc=mirucam@gmail.com \
    --cc=pranit.bauva@gmail.com \
    --cc=tanushreetumane@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).