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

From: Dmitry Gutov <[email-masked]>
Date: Thu, 16 Jun 2016 14:25:19 +0300

On 06/16/2016 10:41 AM, Phillip Lord wrote:

> Well, it uses the directory that GIT_DIR points to (so
> master/.git/worktrees/emacs-25 contains COMMIT_MSG, HEAD, index and so
> on).
>
> Whether is uses GIT_DIR, who knows. I pressume that all git commands
> obey GIT_DIR.

Well, maybe it's used internally. It's of no concern to us here.

> It's certainly true that it would nice to fix it elsewhere, but I am
> unconvinced that setting the mode-line should ever result in an error as
> a normal part of it's operation.

It shouldn't. But it should let the user know that something's going 
wrong, so they can file a bug report.

> Yep; I guess, we know exactly what vc-git--call does with git, and if it
> never depends on GIT_DIR that should work. Although setting and
> unsetting GIT_DIR seems a bit of a pain.

How come? It'll be about as short as your current patch, if not shorter.

> Personally, I prefer my first option of calling git consistently --
> always with CWD equal to root, and always with file paths relative to
> the root. This way, GIT_DIR should not matter.

Let's not be hasty about it. If new arguments arise in favor of this, we 
can do it, but so far unsetting GIT_DIR seems like the cheapest option. 
Like this:

diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index f35c84d..4e495a5 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -1450,7 +1450,9 @@ vc-git--call
           (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))
-	(process-environment (cons "PAGER=" process-environment)))
+	(process-environment (cons
+                              "GIT_DIR="
+                              (cons "PAGER=" process-environment))))
      (apply 'process-file vc-git-program nil buffer nil command args)))

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