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

From: Gregor Zattler <[email-masked]>
Date: Sun, 10 Jan 2010 12:23:11 +0100

Hi Dan,
* Dan Nicolaescu <[email-masked]> [09. Jan. 2010]:
> Gregor Zattler <[email-masked]> writes:
>   > 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.  But in emacs/vc
>   > these dotfiles do not show up as version controlled, even when the emacs
>   > session inherited the correct GIT_* environment variables:
>   > 
>   >    ~$ export GIT_DIR=~/.fgits/emacs.git
>   >    ~$ export GIT_WORK_TREE="$GIT_DIR/$(git config --get core.worktree)"
>   >    ~$ printenv|grep GIT
>   >    GIT_DIR=/home/grfz/.fgits/emacs.git
>   >    GIT_WORK_TREE=/home/grfz/.fgits/emacs.git/../../
> 
> If you want to add support for this, it's quite likely that the only
> thing that needs to be changed is the vc-git-root in
> emacs/lisp/vc-git.el.

Sorry I'm not capable to do this.  That's the reason I called it
a wish list bug.

Because of your suggestion I have fiddled around a bit and found
a workaround which somehow supports your suggestion::

I initilalised an empty repository ~/.git.  Now vc "considers"
my whole home directory as potentially version controlled and
interacts with git.  Git in turn honours the environment
variables and voila:  many of the vc-commands are working now.
Since I do not want to use this ~/.git I did a 
   chmod -R a-w ~/.git
in order to prevent accidentially using this repository in stead
of one of the detached ones.

Thanks for the hint.
Gregor