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

From: Robert Pluim <[email-masked]>
Date: Sun, 01 Dec 2019 17:37:29 +0100

>>>>> On Sun, 01 Dec 2019 11:53:01 +0100, Gregor Zattler <[email-masked]> said:

    Gregor> Hi Lars,
    Gregor> sorry for the delay.
    Gregor> * Lars Ingebrigtsen <[email-masked]> [2019-11-24; 22:46]:
    >> Gregor Zattler <[email-masked]> writes:
    >>> Actually git does it the other way around: It uses the values of
    >>> the environment variables even if there is a .git directory
    >>> further up in the file system hierarchy.  So it's not a fall
    >>> back but it overrides the default.
    >> 
    >> The vc functions in Emacs sets GIT_DIR to "" before calling git, so in
    >> vc mode it would be a fallback.

    Gregor> I don't have much clue but perhaps this is the wrong thing to do?

Itʼs the right thing to do in the context of vc, where it only
supports the directory-based model of repository. Setting GIT_DIR to
"" avoids having the environment of the shell where you started emacs
messing up VC.

    >> It seems like providing a simple alist of directories/git repos would do
    >> the trick in vc-dir, wouldn't it?

No. Define a variable that will be used by vc to override what it
thinks the current repository is, and then use .dir-locals.el to set
it per-directory. Patches welcome :-)

Robert