The native Windows 'git' program prints file names in the form C:/Users/foo/bar . (It is linked with MSYS2, not with Cygwin.) We don't need to call cygpath in this case, but we still need to convert C:/Users/foo/bar -> C:\Users\foo\bar like 'cygpath -w' would do.
2025-05-05 Bruno Haible <br...@clisp.org> windows-cygpath: Make it work with the native Windows 'git' port. * lib/windows-cygpath.c (windows_cygpath_w): When we don't invoke cygpath, still convert slashes to backslashes. diff --git a/lib/windows-cygpath.c b/lib/windows-cygpath.c index f0f1a887ce..8b11898e3d 100644 --- a/lib/windows-cygpath.c +++ b/lib/windows-cygpath.c @@ -121,9 +121,16 @@ windows_cygpath_w (const char *filename) return line; } else - /* It's a relative file name, or an absolute native Windows file name. - No conversion is needed. */ - return xstrdup (filename); + { + /* It's a relative file name, or an absolute native Windows file name. + All we need to do is to convert slashes to backslahes, e.g. + 'C:/Users' -> 'C:\Users'. */ + size_t len = strlen (filename) + 1; + char *copy = XNMALLOC (len, char); + for (size_t i = 0; i < len; i++) + copy[i] = (filename[i] == '/' ? '\\' : filename[i]); + return copy; + } }