]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
vc-mtime: Another fix for native Windows.
authorBruno Haible <bruno@clisp.org>
Mon, 5 May 2025 12:58:51 +0000 (14:58 +0200)
committerBruno Haible <bruno@clisp.org>
Mon, 5 May 2025 12:58:51 +0000 (14:58 +0200)
* lib/vc-mtime.c (SLASH): New macro.
(max_vc_mtime): Use it as expected directory separator in canonicalized
file names.

ChangeLog
lib/vc-mtime.c

index 646f7e268f3ad92ef46629a5198418d84d66cff6..94388f5497bf4be099dd0614db40b4271a2ccbde 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2025-05-05  Bruno Haible  <bruno@clisp.org>
 
+       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.
index 7d792ba33fd393e337d9078c5ee0cabab695a331..77acbabba4e5dc621424f906d79577650a36fdb7 100644 (file)
@@ -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 *);