Re: [PATCH] Introduce the GIT_HOME environment variable
- From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
- Date
- Dec 19, 2009, 17:10 UTC
- Message-ID
- <vpqeimq51pq.fsf@bauges.imag.fr>
- In-Reply-To
- <20091219153046.GG25474@genesis.frugalware.org>
Miklos Vajna <vmiklos@frugalware.org> writes:
> Honor $GIT_HOME that is favoured over $HOME,
I'd personally prefer obeying $XDG_CONFIG_HOME, and read $XDG_CONFIG_HOME/git/config (defaulting to $HOME/.config/git/config) or something like this :
http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html
It solves the same problem ("set on environment variable, and change my whole Git config"), but
* It's a standard. It's really nice to be able to
cd ~/.config ls
to see a user's configuration for many applications at a time, and
cd ~/.config git init
to version-control it.
* It avoids hidden files. With $GIT_CONFIG, a user doing
cd $GIT_HOME ls
sees nothing. I understand why $HOME/something config files are hidden, but a config file stored in a separate directory shouldn't be hidden (just like $GIT_DIR/config is not hidden).
> - const char *home = getenv("HOME");
> + const char *home = getenv("GIT_HOME");
> + if (!home)
> + home = getenv("HOME");If you go this way, why not define
const char *getenv_home()
{
const char *home = getenv("GIT_HOME");
if (!home)
home = getenv("HOME");
return home;
}?
(probably in git-compat-util.h)
-- Matthieu Moy http://www-verimag.imag.fr/~moy/