Subject: Re: bug#78405: 31.0.50; vc-next-action from *vc-diff* on remote file: Git error

From: Dmitry Gutov <[email-masked]>
Date: Thu, 15 May 2025 01:40:48 +0300

On 14/05/2025 17:36, Sean Whitton wrote:
> The FILES-OR-LIST argument to vc-do-command is meant to be VCS-managed
> file names, only.  The temporary patch file is not that, so it shouldn't
> be passed through there.
> 
> The actual bug was that the paths to temporary files were being
> relativised to the repository root by the call to file-relative-name in
> vc-do-command.
> 
> We need to de-TRAMP the temporary file name before passing it to git.

Something like (100% untested)?

diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 4acacaff203..3feb957271a 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -1206,7 +1206,7 @@ vc-git-checkin
            (with-temp-file patch-file
              (insert vc-git-patch-string))
            (unwind-protect
-              (vc-git-command nil 0 nil "apply" "--cached" patch-file)
+              (vc-git-command nil 0 nil "apply" "--cached" 
(file-local-name patch-file))
              (delete-file patch-file))))
        (when to-stash (vc-git--stash-staged-changes to-stash)))
      ;; When operating on the whole tree, better pass "-a" than ".",
@@ -1232,7 +1232,7 @@ vc-git-checkin
          (unwind-protect
              (progn (with-temp-file cached
                       (vc-git-command t 0 nil "stash" "show" "-p"))
-                   (vc-git-command nil 0 nil "apply" "--cached" cached))
+                   (vc-git-command nil 0 nil "apply" "--cached" 
(file-local-name cached)))
            (delete-file cached))
          (vc-git-command nil 0 nil "stash" "drop")))))