From: Bruno Haible Date: Mon, 5 May 2025 12:58:51 +0000 (+0200) Subject: vc-mtime: Another fix for native Windows. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=93fcf9072a0eb904d3c34405dbdfe7815402fbba;p=thirdparty%2Fgnulib.git vc-mtime: Another fix for native Windows. * lib/vc-mtime.c (SLASH): New macro. (max_vc_mtime): Use it as expected directory separator in canonicalized file names. --- diff --git a/ChangeLog b/ChangeLog index 646f7e268f..94388f5497 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2025-05-05 Bruno Haible + vc-mtime: Another fix for native Windows. + * lib/vc-mtime.c (SLASH): New macro. + (max_vc_mtime): Use it as expected directory separator in canonicalized + file names. + vc-mtime: Make it work with Cygwin's 'git' command on native Windows. * lib/vc-mtime.c: Include windows-cygpath.h. (abs_git_checkout): Invoke windows_cygpath_w. diff --git a/lib/vc-mtime.c b/lib/vc-mtime.c index 7d792ba33f..77acbabba4 100644 --- a/lib/vc-mtime.c +++ b/lib/vc-mtime.c @@ -305,6 +305,13 @@ vc_mtime (struct timespec *mtime, const char *filename) /* Keep some safe distance to this maximum. */ #define MAX_CMD_LEN ((int) (MAX_COMMAND_LENGTH * 0.8)) +/* The directory separator in canonicalized file names. */ +#if defined _WIN32 && !defined __CYGWIN__ +# define SLASH '\\' +#else +# define SLASH '/' +#endif + /* Returns the directory name of the git checkout that contains tha current directory, as an absolute file name, or NULL if the current directory is not in a git checkout. */ @@ -555,7 +562,7 @@ max_vc_mtime (struct timespec *max_of_mtimes, char *git_checkout_slash = (strcmp (git_checkout, "/") == 0 ? xstrdup (git_checkout) - : xasprintf ("%s/", git_checkout)); + : xasprintf ("%s%c", git_checkout, SLASH)); char **checkout_relative_filenames = XNMALLOC (nfiles, char *); char **currdir_relative_filenames = XNMALLOC (nfiles, char *);