From: Michael J Gruber <git@drmicha.warpmail.net>
To: Miklos Vajna <vmiklos@frugalware.org>
Cc: Junio C Hamano <gitster@pobox.com>, Moe <moe@signalbeam.net>,
git@vger.kernel.org
Subject: Re: [PATCH] Introduce the GIT_HOME environment variable
Date: Sat, 19 Dec 2009 17:18:25 +0100 [thread overview]
Message-ID: <4B2CFCD1.3010208@drmicha.warpmail.net> (raw)
In-Reply-To: <20091219153046.GG25474@genesis.frugalware.org>
Miklos Vajna venit, vidit, dixit 19.12.2009 16:30:
> Honor $GIT_HOME that is favoured over $HOME, just like $GIT_EDITOR
> overrides $EDITOR. That allows us to extend the notion more naturally
> in the future. For example, when we start reading from
> $HOME/.gitconfig, if the GIT_HOME environment is set, we would instead
> read from $GIT_HOME/.gitconfig.
>
> Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
> ---
>
> On Fri, Dec 18, 2009 at 09:55:07PM -0800, Junio C Hamano <gitster@pobox.com> wrote:
>> A possible solution might be for us to honor $GIT_HOME that is favoured
>> over $HOME, just like $GIT_EDITOR overrides $EDITOR. That allows us to
>> extend the notion more naturally in the future. For example, when we
>> start reading from $HOME/.git-excludes, if the GIT_HOME environment is
>> set, we would instead read from $GIT_HOME/.git-excludes. That would be a
>> much cleaner solution than Miklos's patch [*2*].
>
> Something like this?
>
> I've stolen most of the commit message from your mail. ;-)
Yes, but it makes less sense this way... Junio wrote "when we start
reading" because we don't do that yet. But we read ~/.gitconfig, of
course, so "when we start reading" sounds funny here.
>
> Documentation/config.txt | 14 ++++++++++----
> builtin-config.c | 8 ++++++--
> config.c | 4 +++-
> path.c | 4 +++-
> t/t1300-repo-config.sh | 7 +++++++
> 5 files changed, 29 insertions(+), 8 deletions(-)
>
> diff --git a/Documentation/config.txt b/Documentation/config.txt
> index a1e36d7..09cbc71 100644
> --- a/Documentation/config.txt
> +++ b/Documentation/config.txt
> @@ -8,6 +8,10 @@ is used to store the configuration for that repository, and
> fallback values for the `.git/config` file. The file `/etc/gitconfig`
> can be used to store a system-wide default configuration.
>
> +In case you want to store your per-user configuration in a directory
> +different to `$HOME`, you can use the `$GIT_HOME` environment variable
"different from"
> +which has preference.
> +
> The configuration variables are used by both the git plumbing
> and the porcelains. The variables are divided into sections, wherein
> the fully qualified variable name of the variable itself is the last
> @@ -406,8 +410,9 @@ core.excludesfile::
> In addition to '.gitignore' (per-directory) and
> '.git/info/exclude', git looks into this file for patterns
> of files which are not meant to be tracked. "{tilde}/" is expanded
> - to the value of `$HOME` and "{tilde}user/" to the specified user's
> - home directory. See linkgit:gitignore[5].
> + to the value of `$GIT_HOME` (or `$HOME` if `$GIT_HOME` is not
> + set) and "{tilde}user/" to the specified user's home directory. See
> + linkgit:gitignore[5].
>
> core.editor::
> Commands such as `commit` and `tag` that lets you edit
> @@ -707,8 +712,9 @@ color.ui::
>
> commit.template::
> Specify a file to use as the template for new commit messages.
> - "{tilde}/" is expanded to the value of `$HOME` and "{tilde}user/" to the
> - specified user's home directory.
> + "{tilde}/" is expanded to the value of `$GIT_HOME` (or `$HOME`
> + if `$GIT_HOME` is not set) and "{tilde}user/" to the specified user's
> + home directory.
>
> diff.autorefreshindex::
> When using 'git-diff' to compare with work tree
> diff --git a/builtin-config.c b/builtin-config.c
> index a2d656e..da9ebd4 100644
> --- a/builtin-config.c
> +++ b/builtin-config.c
> @@ -146,7 +146,9 @@ static int get_value(const char *key_, const char *regex_)
>
> local = config_exclusive_filename;
> if (!local) {
> - const char *home = getenv("HOME");
> + const char *home = getenv("GIT_HOME");
> + if (!home)
> + home = getenv("HOME");
> local = repo_config = git_pathdup("config");
> if (git_config_global() && home)
> global = xstrdup(mkpath("%s/.gitconfig", home));
> @@ -326,7 +328,9 @@ int cmd_config(int argc, const char **argv, const char *unused_prefix)
> }
>
> if (use_global_config) {
> - char *home = getenv("HOME");
> + char *home = getenv("GIT_HOME");
> + if (!home)
> + home = getenv("HOME");
> if (home) {
> char *user_config = xstrdup(mkpath("%s/.gitconfig", home));
> config_exclusive_filename = user_config;
> diff --git a/config.c b/config.c
> index 37385ce..7e2ccdb 100644
> --- a/config.c
> +++ b/config.c
> @@ -711,7 +711,9 @@ int git_config(config_fn_t fn, void *data)
> found += 1;
> }
>
> - home = getenv("HOME");
> + home = getenv("GIT_HOME");
> + if (!home)
> + home = getenv("HOME");
> if (git_config_global() && home) {
> char *user_config = xstrdup(mkpath("%s/.gitconfig", home));
> if (!access(user_config, R_OK)) {
> diff --git a/path.c b/path.c
> index 2ec950b..b42a1b6 100644
> --- a/path.c
> +++ b/path.c
> @@ -236,7 +236,9 @@ char *expand_user_path(const char *path)
> const char *username = path + 1;
> size_t username_len = first_slash - username;
> if (username_len == 0) {
> - const char *home = getenv("HOME");
> + const char *home = getenv("GIT_HOME");
> + if (!home)
> + home = getenv("HOME");
> strbuf_add(&user_path, home, strlen(home));
> } else {
> struct passwd *pw = getpw_str(username, username_len);
> diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh
> index 83b7294..d9818ab 100755
> --- a/t/t1300-repo-config.sh
> +++ b/t/t1300-repo-config.sh
> @@ -18,6 +18,13 @@ EOF
>
> test_expect_success 'initial' 'cmp .git/config expect'
>
> +test_expect_success 'GIT_HOME' '
> + GIT_HOME="`pwd`" &&
> + export GIT_HOME &&
> + git config --global core.penguin "little blue" &&
> + cmp "$GIT_HOME"/.gitconfig expect
> +'
> +
> git config Core.Movie BadPhysics
>
> cat > expect << EOF
next prev parent reply other threads:[~2009-12-19 16:18 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-18 22:54 FEATURE REQUEST: Env override GIT_GLOBAL_CONFIG Moe
2009-12-19 1:32 ` [PATCH] Introduce the GIT_CONFIG_EXTRA environment variable Miklos Vajna
2009-12-19 2:09 ` Shawn O. Pearce
2009-12-19 3:06 ` Moe
2009-12-19 14:25 ` Miklos Vajna
2009-12-19 3:24 ` Junio C Hamano
2009-12-19 4:44 ` Moe
2009-12-19 5:55 ` Junio C Hamano
2009-12-19 7:20 ` Moe
2009-12-19 10:54 ` Johannes Schindelin
2009-12-19 11:38 ` Moe
2009-12-19 14:45 ` Nanako Shiraishi
2009-12-19 15:30 ` [PATCH] Introduce the GIT_HOME " Miklos Vajna
2009-12-19 16:18 ` Michael J Gruber [this message]
2009-12-19 16:44 ` Miklos Vajna
2009-12-19 17:10 ` Matthieu Moy
2009-12-19 19:13 ` Junio C Hamano
2009-12-21 10:25 ` Matthieu Moy
2009-12-21 15:59 ` Jeff King
2009-12-21 16:26 ` Matthieu Moy
2009-12-21 16:54 ` Michael J Gruber
2009-12-19 19:21 ` Junio C Hamano
2009-12-20 0:34 ` Miklos Vajna
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B2CFCD1.3010208@drmicha.warpmail.net \
--to=git@drmicha.warpmail.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=moe@signalbeam.net \
--cc=vmiklos@frugalware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.