diff mbox series

[v2,4/7] mingw(is_msys2_sh): handle forward slashes in the `sh.exe` path, too

Message ID f04cfd91bd9a3a462294ea9125e72b3e6bb64865.1720739496.git.gitgitgadget@gmail.com (mailing list archive)
State Superseded
Headers show
Series var(win32): do report the GIT_SHELL_PATH that is actually used | expand

Commit Message

Johannes Schindelin July 11, 2024, 11:11 p.m. UTC
From: Johannes Schindelin <johannes.schindelin@gmx.de>

Whether the full path to the MSYS2 Bash is specified using backslashes
or forward slashes, in either case the command-line arguments need to be
quoted in the MSYS2-specific manner instead of using regular Win32
command-line quoting rules.

In preparation for `prepare_shell_cmd()` to use the full path to
`sh.exe` (with forward slashes for consistency), let's teach the
`is_msys2_sh()` function about this; Otherwise 5580.4 'clone with
backslashed path' would fail once `prepare_shell_cmd()` uses the full
path instead of merely `sh`.

This patch relies on the just-introduced fix where `fspathcmp()` handles
backslashes and forward slashes as equivalent on Windows.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 compat/mingw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Phillip Wood July 12, 2024, 1:49 p.m. UTC | #1
On 12/07/2024 00:11, Johannes Schindelin via GitGitGadget wrote:
> From: Johannes Schindelin <johannes.schindelin@gmx.de>
> 
> Whether the full path to the MSYS2 Bash is specified using backslashes
> or forward slashes, in either case the command-line arguments need to be
> quoted in the MSYS2-specific manner instead of using regular Win32
> command-line quoting rules.
> 
> In preparation for `prepare_shell_cmd()` to use the full path to
> `sh.exe` (with forward slashes for consistency), let's teach the
> `is_msys2_sh()` function about this; Otherwise 5580.4 'clone with
> backslashed path' would fail once `prepare_shell_cmd()` uses the full
> path instead of merely `sh`.

Makes sense

> This patch relies on the just-introduced fix where `fspathcmp()` handles
> backslashes and forward slashes as equivalent on Windows.

That dependency isn't obvious from the patch but there is a call to 
fspathcmp() a couple of lines below the last context line.

Thanks

Phillip

> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
>   compat/mingw.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/compat/mingw.c b/compat/mingw.c
> index 6097b8f9e60..29d3f09768c 100644
> --- a/compat/mingw.c
> +++ b/compat/mingw.c
> @@ -1546,7 +1546,7 @@ static int is_msys2_sh(const char *cmd)
>   		return ret;
>   	}
>   
> -	if (ends_with(cmd, "\\sh.exe")) {
> +	if (ends_with(cmd, "\\sh.exe") || ends_with(cmd, "/sh.exe")) {
>   		static char *sh;
>   
>   		if (!sh)
diff mbox series

Patch

diff --git a/compat/mingw.c b/compat/mingw.c
index 6097b8f9e60..29d3f09768c 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -1546,7 +1546,7 @@  static int is_msys2_sh(const char *cmd)
 		return ret;
 	}
 
-	if (ends_with(cmd, "\\sh.exe")) {
+	if (ends_with(cmd, "\\sh.exe") || ends_with(cmd, "/sh.exe")) {
 		static char *sh;
 
 		if (!sh)