Subject: bug#60011: 30.0.50; git commit from *vc-diff* does not work over tramp

From: Michael Albinus <[email-masked]>
Date: Tue, 13 Dec 2022 19:33:25 +0100

Juri Linkov <[email-masked]> writes:

> Hi Michael,

Hi Juri,

> Could you please confirm that I correctly implemented support for
> Tramp in the following patch.

No.

> diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
> index 83138a6d107..65604e84d0e 100644
> --- a/lisp/vc/vc-git.el
> +++ b/lisp/vc/vc-git.el
> @@ -103,6 +103,7 @@
>  (require 'vc-dispatcher)
>  (eval-when-compile
>    (require 'subr-x) ; for string-trim-right
> +  (require 'tramp)
>    (require 'vc)
>    (require 'vc-dir))
>
> @@ -1048,7 +1049,13 @@ vc-git-checkin
>                          (string-replace file-diff "" vc-git-patch-string))
>                  (user-error "Index not empty"))
>                (setq pos (point))))))
> -      (let ((patch-file (make-temp-file "git-patch")))
> +      (let ((patch-file
> +             (if (file-remote-p default-directory)
> +                 (with-parsed-tramp-file-name
> +                     (expand-file-name default-directory) nil
> +                   (tramp-make-tramp-file-name
> +                    v (with-no-warnings (tramp-make-tramp-temp-file v))))
> +               (make-temp-file "git-patch"))))
>          (with-temp-file patch-file
>            (insert vc-git-patch-string))
>          (unwind-protect

Please don't use Tramp internal functions. As somebody else said in
this thread, make-nearby-temp-file should be good enough.

Best regards, Michael.