mingw: drop the separate `do_lstat()` function

With the new `mingw_stat()` implementation, `do_lstat()` is only called from `mingw_lstat()` (with the function parameter `follow == 0`). Remove the extra function and the old `mingw_stat()`-specific (`follow == 1`) logic. 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>

Karsten Blees committed Jan 9, 2026 at 20:05 UTC 882e5e05282758c736bba4e719c5f6f626986fe7
1 file changed +2 -21
compat/mingw.c
+2 -21
@@ -917,15 +917,7 @@ static int has_valid_directory_prefix(wchar_t *wfilename)
917 return 1;
918 }
919
920 -/* We keep the do_lstat code in a separate function to avoid recursion.
921 - * When a path ends with a slash, the call to `GetFileAttributedExW()`
922 - * would fail. To prevent this, we strip any trailing slashes before that
923 - * call.
924 - *
925 - * If follow is true then act like stat() and report on the link
926 - * target. Otherwise report on the link itself.
927 - */
928 -static int do_lstat(int follow, const char *file_name, struct stat *buf)
920 +int mingw_lstat(const char *file_name, struct stat *buf)
921 {
922 WIN32_FILE_ATTRIBUTE_DATA fdata;
923 wchar_t wfilename[MAX_PATH];
@@ -959,13 +951,7 @@ static int do_lstat(int follow, const char *file_name, struct stat *buf)
951 if (handle != INVALID_HANDLE_VALUE) {
952 if ((findbuf.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) &&
953 (findbuf.dwReserved0 == IO_REPARSE_TAG_SYMLINK)) {
962 - if (follow) {
963 - char buffer[MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
964 - buf->st_size = readlink(file_name, buffer, MAXIMUM_REPARSE_DATA_BUFFER_SIZE);
965 - } else {
966 - buf->st_mode = S_IFLNK;
967 - }
968 - buf->st_mode |= S_IREAD;
954 + buf->st_mode = S_IFLNK | S_IREAD;
955 if (!(findbuf.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
956 buf->st_mode |= S_IWRITE;
957 }
@@ -1023,11 +1009,6 @@ static int get_file_info_by_handle(HANDLE hnd, struct stat *buf)
1009 return 0;
1010 }
1011
1026 -int mingw_lstat(const char *file_name, struct stat *buf)
1027 -{
1028 - return do_lstat(0, file_name, buf);
1029 -}
1030 -
1012 int mingw_stat(const char *file_name, struct stat *buf)
1013 {
1014 wchar_t wfile_name[MAX_PATH];