Subject: Re: bug#5344: 23.1.91; bug/wish: vc does not honour GIT_DIR / GIT_WORK_TREE environment variables

From: Lars Ingebrigtsen <[email-masked]>
Date: Sat, 23 Nov 2019 14:03:33 +0100

Gregor Zattler <[email-masked]> writes:

>  (defun vc-git-root (file)
> -  (vc-find-root file ".git"))
> +(if (getenv "GIT_DIR") 
> +  (getenv "GIT_WORK_TREE")
> + (vc-find-root file ".git")))

As far as I can tell by skimming vc-git.el, functionality like this has
not been added during the intervening years.  The use case it:

> I use bare git repositories for version contol of some dotfiles.[1] This
> means that the repository ist *not* in a .git directory which is part of
> the working directorys hirarchy.  Instead the environment variable
> GIT_DIR indicates the location of the repository and the environment
> variable GIT_WORK_TREE indicates the working directory.

We wouldn't want to add this in the form suggested above, but it does
sound like a useful feature, if I understand it correctly.  But I don't
quite see how you'd tie a specific location to a specific GIT_DIR value,
so I don't see how this would work in general.  Perhaps fall back on
GIT_DIR/GIR_WORK_TREE if vc-git-root returns nil would be reasonable?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no