From bb532b534547d0a6b203baaf2f3379d987f611b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20A=C3=9Fhauer?= Date: Fri, 4 Aug 2023 04:08:42 +0000 Subject: [PATCH 1/3] run-command: conditionally define locate_in_PATH() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit doesn't change any behaviour by itself, but allows us to easily define compat replacements for locate_in_PATH(). It prepares us for the next commit that adds a native Windows implementation of locate_in_PATH(). Signed-off-by: Matthias Aßhauer Signed-off-by: Junio C Hamano --- run-command.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/run-command.c b/run-command.c index 60c9419866..85fc150728 100644 --- a/run-command.c +++ b/run-command.c @@ -170,6 +170,7 @@ int is_executable(const char *name) return st.st_mode & S_IXUSR; } +#ifndef locate_in_PATH /* * Search $PATH for a command. This emulates the path search that * execvp would perform, without actually executing the command so it @@ -218,6 +219,7 @@ static char *locate_in_PATH(const char *file) strbuf_release(&buf); return NULL; } +#endif int exists_in_PATH(const char *command) { From 2bf46a9f62159ced3a84ab8bc9ba151778414bd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20A=C3=9Fhauer?= Date: Fri, 4 Aug 2023 04:08:43 +0000 Subject: [PATCH 2/3] compat/mingw: implement a native locate_in_PATH() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Matthias Aßhauer Signed-off-by: Junio C Hamano --- compat/mingw.c | 5 +++++ compat/mingw.h | 3 +++ 2 files changed, 8 insertions(+) diff --git a/compat/mingw.c b/compat/mingw.c index d06cdc6254..bc3669d298 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 209cf7ceba..b526220596 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 static inline int mingw_SSL_set_fd(SSL *ssl, int fd) From fff1594fa77372ea7a51f6b445267f23fdbf3089 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20A=C3=9Fhauer?= Date: Fri, 4 Aug 2023 04:08:44 +0000 Subject: [PATCH 3/3] docs: update when `git bisect visualize` uses `gitk` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This check has involved more environment variables than just `DISPLAY` since 508e84a790 (bisect view: check for MinGW32 and MacOSX in addition to X11, 2008-02-14), so let's update the documentation accordingly. Signed-off-by: Matthias Aßhauer Signed-off-by: Junio C Hamano --- Documentation/git-bisect.txt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Documentation/git-bisect.txt b/Documentation/git-bisect.txt index fbb39fbdf5..7872dba3ae 100644 --- a/Documentation/git-bisect.txt +++ b/Documentation/git-bisect.txt @@ -204,9 +204,14 @@ as an alternative to `visualize`): $ git bisect visualize ------------ -If the `DISPLAY` environment variable is not set, 'git log' is used -instead. You can also give command-line options such as `-p` and -`--stat`. +Git detects a graphical environment through various environment variables: +`DISPLAY`, which is set in X Window System environments on Unix systems. +`SESSIONNAME`, which is set under Cygwin in interactive desktop sessions. +`MSYSTEM`, which is set under Msys2 and Git for Windows. +`SECURITYSESSIONID`, which may be set on macOS in interactive desktop sessions. + +If none of these environment variables is set, 'git log' is used instead. +You can also give command-line options such as `-p` and `--stat`. ------------ $ git bisect visualize --stat