git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: "Frédéric Brière" <fbriere@fbriere.net>
Cc: git@vger.kernel.org, Jeff King <peff@peff.net>
Subject: Re: $GIT_CONFIG should either apply to all commands, or none at all
Date: Wed, 1 Oct 2014 18:15:46 -0700	[thread overview]
Message-ID: <20141002011546.GR1175@google.com> (raw)
In-Reply-To: <20141002001034.24160.11848.reportbug@fabul.fbriere.net>

Hi,

Frédéric Brière wrote[1]:

> This kind of stuff caused me a lot of hair-pulling:
>
>   $ git config core.abbrev
>   32
>   git log --pretty=oneline --abbrev-commit
>   89be foo
>
> Here's the source of the discrepancy:
>
>   $ grep abbrev $GIT_CONFIG .git/config
>   git.conf:	abbrev=32
>   .git/config:	abbrev=4
>
> Since dc87183, $GIT_CONFIG is ignored by any other Git command, but it
> *still* applies to git-config.  This basically means that values
> obtained via git-config are not necessarily those which are actually in
> effect.
>
> The really frustrating part (for me, at least) is that for any tool
> (gitweb in my case) which uses git-config, values from $GIT_CONFIG will
> take effect for that tool, but not for any subsequent Git command.
>
> git-config(1) doesn't make this clear either; it mentions $GIT_CONFIG as
> "the configuration", without saying explicitly that this environment
> variable only applies to git-config.

Yep.  One possibility would be to do something like the following (A):

 1) advertise in the git-config(1) manpage that the GIT_CONFIG
    environment variable only affects the behavior of the 'git config'
    command

 2) introduce an environment variable GIT_I_AM_PORCELAIN.  (If doing
    this, we could come up with a better name, but this is just an
    illustration.)  Set and export that envvar in git-sh-setup.sh.
    When that environment variable is set, make git-config stop paying
    attention to GIT_CONFIG.

    That way, git commands that happen to be scripts would not be
    affected by the GIT_CONFIG setting any more.

 3) Warn when 'git config' is called with GIT_CONFIG set, explaining
    that support will eventually be removed and that callers should
    pass --file= instead.

 4) Once we're confident there are no scripts in the wild relying on
    that envvar, remove support for it.

Another possibility (B):

 1) Teach git's commands in C to respect the GIT_CONFIG environment
    variable.  Semantics: only configuration from that file would be
    respected and all other configuration will be ignored.  Advertise
    it in the git(1) manpage.

 2) Gnash teeth a little but continue to support it.

Yet another possibility (C):

 1) Just skip to step (4) from plan (A).

C is kind of temping.  Do you know if there are scripts in the wild
that rely on the GIT_CONFIG setting working?

Thanks for reporting,
Jonathan

[1] http://bugs.debian.org/763712

       reply	other threads:[~2014-10-02  1:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20141002001034.24160.11848.reportbug@fabul.fbriere.net>
2014-10-02  1:15 ` Jonathan Nieder [this message]
2014-10-02 15:59   ` $GIT_CONFIG should either apply to all commands, or none at all Jeff King
2014-10-02 17:51   ` Junio C Hamano

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=20141002011546.GR1175@google.com \
    --to=jrnieder@gmail.com \
    --cc=fbriere@fbriere.net \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).