Subject: Re: [PATCH/RFC] Add global and system-wide gitattributes

From: Matthieu Moy <[email-masked]>
Date: Wed, 11 Aug 2010 14:31:16 +0200

Petr Onderka <[email-masked]> writes:

> Allow gitattributes to be set globally and system wide in ~/.giattributes
> and $(prefix)/etc/gitattributes files, respectively. This way, settings
> for particular file types can be set in one place and apply for all user's
> repositories.

The feature is definitely useful, and I'll use it as soon as it gets
into git.git ;-).

One point: we need to make sure the choice for the the user-wide
filename is the right one, since it's a pain to change it later.

We already have ~/.gitconfig, which often points to ~/.gitexcludes or
~/.gitignored (but this filename is specified with a config variable,
for which we didn't manage to agree on a default value). We're about
to add ~/.gitattributes. That makes 3 ~/.git* files, and I think it's
time to make it a directory (similar to $GIT_DIR/info/)

I think it should be done like this:

1) Default core.excludesfile to $CONF/exclude

2) Make your user-wide gitattribute $CONF/attributes

3) Optionally, read $CONF/config as well as ~/.gitconfig so that
   people can have all their git configuration in the same directory.

Now, we need to agree on $CONF. Some non-options are:

* CONF=~/.gitconfig would clash with the file ~/.gitconfig

* CONF=~/.git would prevent people from versionning their $HOME.

I'd be in favor of following the freedesktop standard (roughly,
defaulting to ~/.config/git):

  http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html

because other applications start using it, and it allows one to easily
keep the configuration in a (typically git-versionned) ~/.config
directory. And if we are to choose a config directory, it doesn't harm
to chose one consistant with other applications and with a standard.

I never got time to implement this. If you're willing to do something
like that, that would be great. If not, I'd suggest having a config
variable to point to the user-wide gitattributes file (without a
default value), because it allows a future transition by giving a
default value to the variable.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/