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

From: Juri Linkov <[email-masked]>
Date: Mon, 12 Dec 2022 20:29:09 +0200

> I run Emacs locally (macosx laptop) and edit remote (Amazon Linux "cloud
> desktop") files using tramp (scp).
> I can commit files using vc/git just fine.
> However, when I edit *vc-diff* and hit C-v v v (vc-next-action), and
> then edit the commit message abd hit C-c C-c, I get this error:
>
> Debugger entered--Lisp error: (error "Failed (status 128): git --no-pager apply --cached...")
>   signal(error ("Failed (status 128): git --no-pager apply --cached..."))
>   error("Failed (%s): %s" "status 128" "git --no-pager apply --cached /var/folders/20/__3t...")
>   vc-do-command("*vc*" 0 "git" "/var/folders/20/__3tt7vx6wg51x8xvqdc1cmw0000gr/T/g..." "--no-pager" "apply" "--cached")
>   apply(vc-do-command "*vc*" 0 "git" "/var/folders/20/__3tt7vx6wg51x8xvqdc1cmw0000gr/T/g..." ("--no-pager" "apply" "--cached"))
>   vc-git-command(nil 0 "/var/folders/20/__3tt7vx6wg51x8xvqdc1cmw0000gr/T/g..." "apply" "--cached")
>   vc-git-checkin(nil #("Summary: TEE: split pairs_mx into make_da2mt_mx an..." ...

The problem is in these lines that create a temporary file
on a local directory only:

      (let ((patch-file (make-temp-file "git-patch")))
        (with-temp-file patch-file
          (insert vc-git-patch-string))
        (unwind-protect
            (vc-git-command nil 0 patch-file "apply" "--cached")
          (delete-file patch-file)))

I'm not yet sure whether using make-nearby-temp-file could help
to create a temporary file on a remote directory, need to try.