]> git.ipfire.org Git - thirdparty/git.git/commit - compat/mingw.c
mingw: fix launching of externals from Unicode paths
authorAdam Roben <adam@roben.org>
Sat, 24 Aug 2019 22:38:56 +0000 (15:38 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 26 Aug 2019 17:06:03 +0000 (10:06 -0700)
commit4e1a641ee345bbc877ed82962e12c45f09b6617b
tree51d518ed0d44e3ce0e80558113fcad9cb56ec2ab
parent745f6812895b31c02b29bdfe4ae8e5498f776c26
mingw: fix launching of externals from Unicode paths

If Git were installed in a path containing non-ASCII characters,
commands such as `git am` and `git submodule`, which are implemented as
externals, would fail to launch with the following error:

> fatal: 'am' appears to be a git command, but we were not
> able to execute it. Maybe git-am is broken?

This was due to lookup_prog not being Unicode-aware. It was somehow
missed in 85faec9d3a (Win32: Unicode file name support (except dirent),
2012-03-15).

Note that the only problem in this function was calling
`GetFileAttributes()` instead of `GetFileAttributesW()`. The calls to
`access()` were fine because `access()` is a macro which resolves to
`mingw_access()`, which already handles Unicode correctly. But
`lookup_prog()` was changed to use `_waccess()` directly so that we only
convert the path to UTF-16 once.

To make things work correctly, we have to maintain UTF-8 and UTF-16
versions in tandem in `lookup_prog()`.

Signed-off-by: Adam Roben <adam@roben.org>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
compat/mingw.c