> vc-mtime: Add API for more efficient use of git. Two more patches are needed, to make it work on native Windows.
2025-05-05 Bruno Haible <br...@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. * modules/vc-mtime (Depends-on): Add windows-cygpath.
>From e5190b5161f992e789c4e749d38ba7d92f429e0d Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Mon, 5 May 2025 11:40:06 +0200 Subject: [PATCH 1/2] 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. * modules/vc-mtime (Depends-on): Add windows-cygpath. --- ChangeLog | 7 +++++++ lib/vc-mtime.c | 7 ++++++- modules/vc-mtime | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 7c790cdff3..646f7e268f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2025-05-05 Bruno Haible <br...@clisp.org> + + 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. + * modules/vc-mtime (Depends-on): Add windows-cygpath. + 2025-05-05 Bruno Haible <br...@clisp.org> New module windows-cygpath. diff --git a/lib/vc-mtime.c b/lib/vc-mtime.c index 4ebc249d84..7d792ba33f 100644 --- a/lib/vc-mtime.c +++ b/lib/vc-mtime.c @@ -35,6 +35,7 @@ #include "safe-read.h" #include "xstrtol.h" #include "stat-time.h" +#include "windows-cygpath.h" #include "filename.h" #include "xalloc.h" #include "xgetcwd.h" @@ -357,7 +358,11 @@ abs_git_checkout (void) exitstatus = wait_subprocess (child, "git", true, true, true, false, NULL); if (exitstatus == 0) - return line; + { + char *line_converted = windows_cygpath_w (line); + free (line); + return line_converted; + } } free (line); return NULL; diff --git a/modules/vc-mtime b/modules/vc-mtime index 207e62781c..b4f74f5d36 100644 --- a/modules/vc-mtime +++ b/modules/vc-mtime @@ -16,6 +16,7 @@ error getline xstrtol stat-time +windows-cygpath filename xalloc xgetcwd -- 2.43.0
>From 93fcf9072a0eb904d3c34405dbdfe7815402fbba Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Mon, 5 May 2025 14:58:51 +0200 Subject: [PATCH 2/2] 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. --- ChangeLog | 5 +++++ lib/vc-mtime.c | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 646f7e268f..94388f5497 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2025-05-05 Bruno Haible <br...@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. 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 *); -- 2.43.0