Subject: Re: bug#23769: 25.0.95; Mode Line breakage in vc-git

From: Dmitry Gutov <[email-masked]>
Date: Fri, 17 Jun 2016 05:41:04 +0300

On 06/17/2016 01:42 AM, Phillip Lord wrote:

> A problem as "GIT_DIR" on it's own, still breaks with my originally
> reported error (at least when running my ert test I sent with my patch).
>
> Are you not getting this failure also?

Sorry, I was only testing that the addition doesn't break anything in 
the normal case, otherwise relying on process-environment's docstring.

There was a problem with the patch that not all vc-git code goes through 
vc-git--call (in fact, most don't), but even patching vc-git-command in 
a similar fashion doesn't change the behavior if Emacs was started with 
GIT_DIR=.git.

Could this feature be actually broken? Or how does Git ignore the 
modification?

"To use ‘process-environment’ to
remove an environment variable, include only its name in the list,
without "=VALUE"."

diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index f35c84d..a544a2e 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -1423,7 +1423,9 @@ vc-git-command
    (let ((coding-system-for-read
           (or coding-system-for-read vc-git-log-output-coding-system))
  	(coding-system-for-write
-         (or coding-system-for-write vc-git-commits-coding-system)))
+         (or coding-system-for-write vc-git-commits-coding-system))
+        (process-environment process-environment))
+    (push "GIT_DIR" process-environment)
      (apply 'vc-do-command (or buffer "*vc*") okstatus vc-git-program
  	   ;; http://debbugs.gnu.org/16897
  	   (unless (and (not (cdr-safe file-or-list))
@@ -1451,6 +1453,7 @@ vc-git--call
  	(coding-system-for-write
           (or coding-system-for-write vc-git-commits-coding-system))
  	(process-environment (cons "PAGER=" process-environment)))
+    (push "GIT_DIR" process-environment)
      (apply 'process-file vc-git-program nil buffer nil command args)))

  (defun vc-git--out-ok (command &rest args)