git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* git makes it impossible to ignore or override global gitconfig, needs `GITCONFIGFILE`
@ 2020-03-19  5:48 Timothee Cour
  2020-03-19  6:44 ` Eric Wong
  0 siblings, 1 reply; 5+ messages in thread
From: Timothee Cour @ 2020-03-19  5:48 UTC (permalink / raw)
  To: git

git makes it impossible to ignore global gitconfig. This is
essentially what's being asked here:
https://stackoverflow.com/questions/23400449/how-to-make-git-temporarily-ignore-gitconfig

## proposal:
add an environment variable (like for tig and other programs), eg:
`GITCONFIGFILE=~/.gitconfig_temp git diff`
seems like an easy change that would make it easy for users to ignore
or override their gitconfig

## note:
I've asked here:
https://groups.google.com/forum/#!topic/git-users/1ehWsItL8vE but got
0 response after 6 months

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: git makes it impossible to ignore or override global gitconfig, needs `GITCONFIGFILE`
  2020-03-19  5:48 git makes it impossible to ignore or override global gitconfig, needs `GITCONFIGFILE` Timothee Cour
@ 2020-03-19  6:44 ` Eric Wong
  2020-03-19 16:51   ` Jeff King
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Wong @ 2020-03-19  6:44 UTC (permalink / raw)
  To: Timothee Cour; +Cc: git

Timothee Cour <thelastmammoth@gmail.com> wrote:
> git makes it impossible to ignore global gitconfig. This is
> essentially what's being asked here:
> https://stackoverflow.com/questions/23400449/how-to-make-git-temporarily-ignore-gitconfig
> 
> ## proposal:
> add an environment variable (like for tig and other programs), eg:
> `GITCONFIGFILE=~/.gitconfig_temp git diff`
> seems like an easy change that would make it easy for users to ignore
> or override their gitconfig

You can use GIT_CONFIG for that, and there's also
GIT_CONFIG_NOSYSTEM.  They're both documented in the
git-config(5) manpage.

> ## note:
> I've asked here:
> https://groups.google.com/forum/#!topic/git-users/1ehWsItL8vE but got
> 0 response after 6 months

Oh well...  I don't pay any attention to that list, and not too
much to this one, either.  I was just working on the archives
and noticed this was the latest message on this list :>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: git makes it impossible to ignore or override global gitconfig, needs `GITCONFIGFILE`
  2020-03-19  6:44 ` Eric Wong
@ 2020-03-19 16:51   ` Jeff King
  2020-03-20  2:28     ` Timothee Cour
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff King @ 2020-03-19 16:51 UTC (permalink / raw)
  To: Eric Wong; +Cc: Timothee Cour, git

On Thu, Mar 19, 2020 at 06:44:07AM +0000, Eric Wong wrote:

> Timothee Cour <thelastmammoth@gmail.com> wrote:
> > git makes it impossible to ignore global gitconfig. This is
> > essentially what's being asked here:
> > https://stackoverflow.com/questions/23400449/how-to-make-git-temporarily-ignore-gitconfig
> > 
> > ## proposal:
> > add an environment variable (like for tig and other programs), eg:
> > `GITCONFIGFILE=~/.gitconfig_temp git diff`
> > seems like an easy change that would make it easy for users to ignore
> > or override their gitconfig
> 
> You can use GIT_CONFIG for that, and there's also
> GIT_CONFIG_NOSYSTEM.  They're both documented in the
> git-config(5) manpage.

I don't think $GIT_CONFIG is what Timothee whats. It only affects the
git-config command, not config lookup in other programs. And it
overrides _all_ config lookup, as if "git config --file" had been used.

There's no variable to suppress just the user-level gitconfig. The usual
technique (that we use in the test scripts) is to point $HOME somewhere
else, but that may affect other programs.

I wouldn't be opposed to GIT_CONFIG_NOGLOBAL if there's a use case, but
it sounds like the desire is to actually provide new config. That can
also be done for specific options with "git -c". Under the hood that is
using GIT_CONFIG_PARAMETERS in the environment; you can set it
individually, but note that it's a little picky about quoting (the
individual keys are shell-quoted, but it insists that there is an outer
layer of single-quotes, even if they weren't necessary; I wouldn't be
opposed to making it more friendly). You can see what it produces like
this:

  git -c alias.dump='!echo "$GIT_CONFIG_PARAMETERS"' dump

-Peff

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: git makes it impossible to ignore or override global gitconfig, needs `GITCONFIGFILE`
  2020-03-19 16:51   ` Jeff King
@ 2020-03-20  2:28     ` Timothee Cour
  2020-03-20  5:41       ` Jeff King
  0 siblings, 1 reply; 5+ messages in thread
From: Timothee Cour @ 2020-03-20  2:28 UTC (permalink / raw)
  To: Jeff King; +Cc: Eric Wong, Timothee Cour, git

* GIT_CONFIG doesn't work as you mentioned and as was already
mentioned in https://stackoverflow.com/questions/23400449/how-to-make-git-temporarily-ignore-gitconfig
* `HOME= `doesn't work for many reasons: it breaks other commands as
you mentioned, it breaks `~`, and it doesn't work if users' git config
is in /Users/timothee/.config//git/config ; and pointing it to an
alternate home where you'd have `newhome/.gitconfig`  would require a
lot of workarounds to update paths including `~`
*  `XDG_CONFIG_HOME= ` also doesn't work (even if users' git config is
in /Users/timothee/.config//git/config), which really seems buggy,
eg:`XDG_CONFIG_HOME= git diff HEAD^` is still reading
`/Users/timothee/.config//git/config` somehow
* GIT_CONFIG_NOGLOBAL is also not good, I want to be able to simply
point my config to some place else, not simply suppress reading git
config
* require passing commands (eg `git -c`) is not good either; it'd
require updating scripts that rely on git (this could be arbitrarily
complex, sometimes impossible if you just have a binary and no source
code access)

In contrast, what I'm suggesting is extremely simple to use, robust,
and my understanding is it shouldn't be hard to implement.
```
GITCONFIGFILE=   git diff HEAD^ # empty config
GITCONFIGFILE=/pathto/gitconfig2   git diff HEAD^ # uses specified git
config file
GITCONFIGFILE=/pathto/gitconfig2   run_some_complex_script # uses
specified git config file everywhere
```
by contrast, any approach based on passing command line flag (eg `git
-c /pathto/gitconfig2 diff HEAD^`) will make the last case impossible
to do since you'd need to update every git command inside (which could
be in a compiled binary, etc)

What i'm asking is the analog of `TIGRC_USER` for tig
(https://jonas.github.io/tig/doc/tig.1.html) and many other programs

On Thu, Mar 19, 2020 at 9:51 AM Jeff King <peff@peff.net> wrote:
>
> On Thu, Mar 19, 2020 at 06:44:07AM +0000, Eric Wong wrote:
>
> > Timothee Cour <thelastmammoth@gmail.com> wrote:
> > > git makes it impossible to ignore global gitconfig. This is
> > > essentially what's being asked here:
> > > https://stackoverflow.com/questions/23400449/how-to-make-git-temporarily-ignore-gitconfig
> > >
> > > ## proposal:
> > > add an environment variable (like for tig and other programs), eg:
> > > `GITCONFIGFILE=~/.gitconfig_temp git diff`
> > > seems like an easy change that would make it easy for users to ignore
> > > or override their gitconfig
> >
> > You can use GIT_CONFIG for that, and there's also
> > GIT_CONFIG_NOSYSTEM.  They're both documented in the
> > git-config(5) manpage.
>
> I don't think $GIT_CONFIG is what Timothee whats. It only affects the
> git-config command, not config lookup in other programs. And it
> overrides _all_ config lookup, as if "git config --file" had been used.
>
> There's no variable to suppress just the user-level gitconfig. The usual
> technique (that we use in the test scripts) is to point $HOME somewhere
> else, but that may affect other programs.
>
> I wouldn't be opposed to GIT_CONFIG_NOGLOBAL if there's a use case, but
> it sounds like the desire is to actually provide new config. That can
> also be done for specific options with "git -c". Under the hood that is
> using GIT_CONFIG_PARAMETERS in the environment; you can set it
> individually, but note that it's a little picky about quoting (the
> individual keys are shell-quoted, but it insists that there is an outer
> layer of single-quotes, even if they weren't necessary; I wouldn't be
> opposed to making it more friendly). You can see what it produces like
> this:
>
>   git -c alias.dump='!echo "$GIT_CONFIG_PARAMETERS"' dump
>
> -Peff

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: git makes it impossible to ignore or override global gitconfig, needs `GITCONFIGFILE`
  2020-03-20  2:28     ` Timothee Cour
@ 2020-03-20  5:41       ` Jeff King
  0 siblings, 0 replies; 5+ messages in thread
From: Jeff King @ 2020-03-20  5:41 UTC (permalink / raw)
  To: Timothee Cour; +Cc: Eric Wong, git

On Thu, Mar 19, 2020 at 07:28:58PM -0700, Timothee Cour wrote:

> * require passing commands (eg `git -c`) is not good either; it'd
> require updating scripts that rely on git (this could be arbitrarily
> complex, sometimes impossible if you just have a binary and no source
> code access)

Well, yes, that's why I suggested setting $GIT_CONFIG_PARAMETERS
directly. :)

That said, I don't have any real opposition to an environment variable
to override the user-level config location, if somebody wants to work up
a patch. A few preliminary thoughts:

 - there are several levels of config file, so it probably should be
   called GIT_GLOBAL_CONFIG or something to make it clear that it
   matches "config --global" (and not system or repo-level config)

 - we'll read user-level config from multiple sources currently:
   ~/.gitconfig and the xdg config dir. Presumably this would override
   them rather than add to them to be of any use.

 - I wondered for a moment if such a variable would need to be added to
   local_repo_env[] to get cleared when moving between repos. But as a
   user-level thing, it should be outside that.

-Peff

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-03-20  5:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-19  5:48 git makes it impossible to ignore or override global gitconfig, needs `GITCONFIGFILE` Timothee Cour
2020-03-19  6:44 ` Eric Wong
2020-03-19 16:51   ` Jeff King
2020-03-20  2:28     ` Timothee Cour
2020-03-20  5:41       ` Jeff King

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).