]> git.ipfire.org Git - thirdparty/git.git/commit
mingw: don't call `GetFileAttributes()` twice in `mingw_lstat()`
authorKarsten Blees <karsten.blees@gmail.com>
Fri, 9 Jan 2026 20:04:58 +0000 (20:04 +0000)
committerJunio C Hamano <gitster@pobox.com>
Sat, 10 Jan 2026 02:32:54 +0000 (18:32 -0800)
commit3b96b99683679ee0d0c4e05cb5d1da37e13e02e5
tree3476dd26681815260a0221ecde6a984e2f2bdd57
parentec13dca8d0619dc1cfe4cee5801b32bc58792ae2
mingw: don't call `GetFileAttributes()` twice in `mingw_lstat()`

The Win32 API function `GetFileAttributes()` cannot handle paths with
trailing dir separators. The current `mingw_stat()`/`mingw_lstat()`
implementation calls `GetFileAttributes()` twice if the path has
trailing slashes (first with the original path that was passed as
function parameter, and and a second time with a path copy with trailing
'/' removed).

With the conversion to wide Unicode, we get the length of the path for
free, and also have a (wide char) buffer that can be modified. This
makes it easy to avoid that extraneous Win32 API call.

Signed-off-by: Karsten Blees <karsten.blees@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
compat/mingw.c