From a219ee8c314506d4105d9767fe7332d3fd8525a5 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Fri, 1 Sep 2023 16:08:36 +0300 Subject: [PATCH] Fix minor bugs in vc-git and vc-hg on Windows uncovered by vc-tests * lisp/vc/vc-hg.el (vc-hg-state-slow): Non-existing files emit a different message on MS-Windows; support that. * lisp/vc/vc-git.el (vc-git-checkin): Make sure 'default-directory' is not nil when calling 'make-nearby-temp-file' on MS-Windows. * test/lisp/vc/vc-tests.el (vc-test--version-diff): Run 'default-directory' through 'file-truename', otherwise the 'vc-test-cvs06-version-diff' test might fail on MS-Windows. --- lisp/vc/vc-git.el | 3 ++- lisp/vc/vc-hg.el | 5 ++++- test/lisp/vc/vc-tests.el | 5 +++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 218696c05f4..fe6215f47b8 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -1014,7 +1014,8 @@ It is based on `log-edit-mode', and has Git-specific extensions." ;; might not support the non-ASCII characters in the log ;; message. Handle also remote files. (if (eq system-type 'windows-nt) - (let ((default-directory (file-name-directory file1))) + (let ((default-directory (or (file-name-directory file1) + default-directory))) (make-nearby-temp-file "git-msg"))))) (when vc-git-patch-string (unless (zerop (vc-git-command nil t nil "diff" "--cached" "--quiet")) diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el index 5bab9aa529e..a89e6520055 100644 --- a/lisp/vc/vc-hg.el +++ b/lisp/vc/vc-hg.el @@ -249,7 +249,10 @@ If `ask', you will be prompted for a branch type." (error nil))))))) (when (and (eq 0 status) (> (length out) 0) - (null (string-match ".*: No such file or directory$" out))) + ;; Posix + (null (or (string-match ".*: No such file or directory$" out) + ;; MS-Windows + (string-match ".*: The system cannot find the file specified$" out)))) (let ((state (aref out 0))) (cond ((eq state ?=) 'up-to-date) diff --git a/test/lisp/vc/vc-tests.el b/test/lisp/vc/vc-tests.el index 11c20d2783c..0a26e25e32a 100644 --- a/test/lisp/vc/vc-tests.el +++ b/test/lisp/vc/vc-tests.el @@ -596,8 +596,9 @@ This checks also `vc-backend' and `vc-responsible-backend'." (let ((vc-handled-backends `(,backend)) (default-directory (file-name-as-directory - (expand-file-name - (make-temp-name "vc-test") temporary-file-directory))) + (file-truename + (expand-file-name + (make-temp-name "vc-test") temporary-file-directory)))) (process-environment process-environment) vc-test--cleanup-hook) (when (eq backend 'Bzr) -- 2.39.2