Subject: Re: bug#23952: 25.0.95; Regression: vc (git) over TRAMP doesn't work anymore

From: Michael Albinus <[email-masked]>
Date: Tue, 12 Jul 2016 09:43:58 +0200

Dima Kogan <[email-masked]> writes:

> Hi.

Hi,

> I'm running a very recent emacs built from git (658daf9). In the
> last two weeks or so, remote VC mode stopped working. Recipe:
>
> 1. emacs -Q
> 2. C-x C-f /127.0.0.1:emacs (or any other remote path that has a git
>    repo)
> 3. C-x C-v D (or any other VC-mode function)
>
> Instead of seeing VC mode do its thing it now throws an error:
>
>   env: ‘GIT_DIR’: No such file or directory

This is due to Bug#23769, adding "GIT_DIR" to `process-environment'.
Tramp handles properly entries like "key=value" and "key=", entries like
"key" are not handled properly yet.

The following patch towards the emacs-25 branch fixes this:

--8<---------------cut here---------------start------------->8---
*** /home/albinus/src/emacs-25/lisp/net/tramp-sh.el.~f981b3136742a8597674dd4915afeb1b220a0464~	2016-07-12 09:41:08.663542129 +0200
--- /home/albinus/src/emacs-25/lisp/net/tramp-sh.el	2016-07-12 09:41:03.843470688 +0200
***************
*** 3034,3040 ****
  		 (cons prompt (nreverse (copy-sequence process-environment)))
  		 env)
  	      (or (member elt (default-toplevel-value 'process-environment))
! 		  (setq env (cons elt env)))))
  	   (command
  	    (when (stringp program)
  	      (format "cd %s && exec %s env %s %s"
--- 3034,3043 ----
  		 (cons prompt (nreverse (copy-sequence process-environment)))
  		 env)
  	      (or (member elt (default-toplevel-value 'process-environment))
!                   (setq env
!                         (if (string-match "=" elt)
!                             (append env `(,elt))
!                           (append `("-u" ,elt) env))))))
  	   (command
  	    (when (stringp program)
  	      (format "cd %s && exec %s env %s %s"
***************
*** 3135,3141 ****
        (setq env
  	    (dolist (elt (nreverse (copy-sequence process-environment)) env)
  	      (or (member elt (default-toplevel-value 'process-environment))
! 		  (setq env (cons elt env)))))
        (when env
  	(setq command
  	      (format
--- 3138,3147 ----
        (setq env
  	    (dolist (elt (nreverse (copy-sequence process-environment)) env)
  	      (or (member elt (default-toplevel-value 'process-environment))
!                   (setq env
!                         (if (string-match "=" elt)
!                             (append env `(,elt))
!                           (append `("-u" ,elt) env))))))
        (when env
  	(setq command
  	      (format
--8<---------------cut here---------------end--------------->8---

Should this be pushed to the emacs-25 branch, or to master?

Best regards, Michael.