{"thread":{"id":"53029","subject":"git makes it impossible to ignore or override global gitconfig, needs `GITCONFIGFILE`","startedAt":"2020-03-19T05:48:47Z","lastAt":"2020-03-20T05:41:05Z","messageCount":5,"participants":["Timothee Cour","Eric Wong","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"393438","messageId":"CANri+Ey71QbWxNH+RhMfYuUSDEpYtv28ushUhK8Tt0xWUAU9iw@mail.gmail.com","threadId":"53029","inReplyTo":null,"subject":"git makes it impossible to ignore or override global gitconfig, needs `GITCONFIGFILE`","fromName":"Timothee Cour","fromEmail":"thelastmammoth@gmail.com","sentAt":"2020-03-19T05:48:17Z","receivedAt":"2020-03-19T05:48:47Z","isPatch":false,"sender":{"key":"thelastmammoth@gmail.com","avatar":null},"body":"git makes it impossible to ignore global gitconfig. This is\nessentially what's being asked here:\nhttps://stackoverflow.com/questions/23400449/how-to-make-git-temporarily-ignore-gitconfig\n\n## proposal:\nadd an environment variable (like for tig and other programs), eg:\n`GITCONFIGFILE=~/.gitconfig_temp git diff`\nseems like an easy change that would make it easy for users to ignore\nor override their gitconfig\n\n## note:\nI've asked here:\nhttps://groups.google.com/forum/#!topic/git-users/1ehWsItL8vE but got\n0 response after 6 months\n"},{"id":"393439","messageId":"20200319064407.GA26408@dcvr","threadId":"53029","inReplyTo":"CANri+Ey71QbWxNH+RhMfYuUSDEpYtv28ushUhK8Tt0xWUAU9iw@mail.gmail.com","subject":"Re: git makes it impossible to ignore or override global gitconfig, needs `GITCONFIGFILE`","fromName":"Eric Wong","fromEmail":"e@yhbt.net","sentAt":"2020-03-19T06:44:07Z","receivedAt":"2020-03-19T06:44:09Z","isPatch":false,"sender":{"key":"e@yhbt.net","avatar":null},"body":"Timothee Cour <thelastmammoth@gmail.com> wrote:\n> git makes it impossible to ignore global gitconfig. This is\n> essentially what's being asked here:\n> https://stackoverflow.com/questions/23400449/how-to-make-git-temporarily-ignore-gitconfig\n> \n> ## proposal:\n> add an environment variable (like for tig and other programs), eg:\n> `GITCONFIGFILE=~/.gitconfig_temp git diff`\n> seems like an easy change that would make it easy for users to ignore\n> or override their gitconfig\n\nYou can use GIT_CONFIG for that, and there's also\nGIT_CONFIG_NOSYSTEM.  They're both documented in the\ngit-config(5) manpage.\n\n> ## note:\n> I've asked here:\n> https://groups.google.com/forum/#!topic/git-users/1ehWsItL8vE but got\n> 0 response after 6 months\n\nOh well...  I don't pay any attention to that list, and not too\nmuch to this one, either.  I was just working on the archives\nand noticed this was the latest message on this list :>\n"},{"id":"393472","messageId":"20200319165149.GA4074934@coredump.intra.peff.net","threadId":"53029","inReplyTo":"20200319064407.GA26408@dcvr","subject":"Re: git makes it impossible to ignore or override global gitconfig, needs `GITCONFIGFILE`","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2020-03-19T16:51:49Z","receivedAt":"2020-03-19T16:51:51Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Mar 19, 2020 at 06:44:07AM +0000, Eric Wong wrote:\n\n> Timothee Cour <thelastmammoth@gmail.com> wrote:\n> > git makes it impossible to ignore global gitconfig. This is\n> > essentially what's being asked here:\n> > https://stackoverflow.com/questions/23400449/how-to-make-git-temporarily-ignore-gitconfig\n> > \n> > ## proposal:\n> > add an environment variable (like for tig and other programs), eg:\n> > `GITCONFIGFILE=~/.gitconfig_temp git diff`\n> > seems like an easy change that would make it easy for users to ignore\n> > or override their gitconfig\n> \n> You can use GIT_CONFIG for that, and there's also\n> GIT_CONFIG_NOSYSTEM.  They're both documented in the\n> git-config(5) manpage.\n\nI don't think $GIT_CONFIG is what Timothee whats. It only affects the\ngit-config command, not config lookup in other programs. And it\noverrides _all_ config lookup, as if \"git config --file\" had been used.\n\nThere's no variable to suppress just the user-level gitconfig. The usual\ntechnique (that we use in the test scripts) is to point $HOME somewhere\nelse, but that may affect other programs.\n\nI wouldn't be opposed to GIT_CONFIG_NOGLOBAL if there's a use case, but\nit sounds like the desire is to actually provide new config. That can\nalso be done for specific options with \"git -c\". Under the hood that is\nusing GIT_CONFIG_PARAMETERS in the environment; you can set it\nindividually, but note that it's a little picky about quoting (the\nindividual keys are shell-quoted, but it insists that there is an outer\nlayer of single-quotes, even if they weren't necessary; I wouldn't be\nopposed to making it more friendly). You can see what it produces like\nthis:\n\n  git -c alias.dump='!echo \"$GIT_CONFIG_PARAMETERS\"' dump\n\n-Peff\n"},{"id":"393511","messageId":"CANri+EzrP0TeHTfjhsf=LZkwkEZU7fSRnnKN9NLga7CNow9F0Q@mail.gmail.com","threadId":"53029","inReplyTo":"20200319165149.GA4074934@coredump.intra.peff.net","subject":"Re: git makes it impossible to ignore or override global gitconfig, needs `GITCONFIGFILE`","fromName":"Timothee Cour","fromEmail":"timothee.cour2@gmail.com","sentAt":"2020-03-20T02:28:58Z","receivedAt":"2020-03-20T02:29:26Z","isPatch":false,"sender":{"key":"timothee.cour2@gmail.com","avatar":null},"body":"* GIT_CONFIG doesn't work as you mentioned and as was already\nmentioned in https://stackoverflow.com/questions/23400449/how-to-make-git-temporarily-ignore-gitconfig\n* `HOME= `doesn't work for many reasons: it breaks other commands as\nyou mentioned, it breaks `~`, and it doesn't work if users' git config\nis in /Users/timothee/.config//git/config ; and pointing it to an\nalternate home where you'd have `newhome/.gitconfig`  would require a\nlot of workarounds to update paths including `~`\n*  `XDG_CONFIG_HOME= ` also doesn't work (even if users' git config is\nin /Users/timothee/.config//git/config), which really seems buggy,\neg:`XDG_CONFIG_HOME= git diff HEAD^` is still reading\n`/Users/timothee/.config//git/config` somehow\n* GIT_CONFIG_NOGLOBAL is also not good, I want to be able to simply\npoint my config to some place else, not simply suppress reading git\nconfig\n* require passing commands (eg `git -c`) is not good either; it'd\nrequire updating scripts that rely on git (this could be arbitrarily\ncomplex, sometimes impossible if you just have a binary and no source\ncode access)\n\nIn contrast, what I'm suggesting is extremely simple to use, robust,\nand my understanding is it shouldn't be hard to implement.\n```\nGITCONFIGFILE=   git diff HEAD^ # empty config\nGITCONFIGFILE=/pathto/gitconfig2   git diff HEAD^ # uses specified git\nconfig file\nGITCONFIGFILE=/pathto/gitconfig2   run_some_complex_script # uses\nspecified git config file everywhere\n```\nby contrast, any approach based on passing command line flag (eg `git\n-c /pathto/gitconfig2 diff HEAD^`) will make the last case impossible\nto do since you'd need to update every git command inside (which could\nbe in a compiled binary, etc)\n\nWhat i'm asking is the analog of `TIGRC_USER` for tig\n(https://jonas.github.io/tig/doc/tig.1.html) and many other programs\n\nOn Thu, Mar 19, 2020 at 9:51 AM Jeff King <peff@peff.net> wrote:\n>\n> On Thu, Mar 19, 2020 at 06:44:07AM +0000, Eric Wong wrote:\n>\n> > Timothee Cour <thelastmammoth@gmail.com> wrote:\n> > > git makes it impossible to ignore global gitconfig. This is\n> > > essentially what's being asked here:\n> > > https://stackoverflow.com/questions/23400449/how-to-make-git-temporarily-ignore-gitconfig\n> > >\n> > > ## proposal:\n> > > add an environment variable (like for tig and other programs), eg:\n> > > `GITCONFIGFILE=~/.gitconfig_temp git diff`\n> > > seems like an easy change that would make it easy for users to ignore\n> > > or override their gitconfig\n> >\n> > You can use GIT_CONFIG for that, and there's also\n> > GIT_CONFIG_NOSYSTEM.  They're both documented in the\n> > git-config(5) manpage.\n>\n> I don't think $GIT_CONFIG is what Timothee whats. It only affects the\n> git-config command, not config lookup in other programs. And it\n> overrides _all_ config lookup, as if \"git config --file\" had been used.\n>\n> There's no variable to suppress just the user-level gitconfig. The usual\n> technique (that we use in the test scripts) is to point $HOME somewhere\n> else, but that may affect other programs.\n>\n> I wouldn't be opposed to GIT_CONFIG_NOGLOBAL if there's a use case, but\n> it sounds like the desire is to actually provide new config. That can\n> also be done for specific options with \"git -c\". Under the hood that is\n> using GIT_CONFIG_PARAMETERS in the environment; you can set it\n> individually, but note that it's a little picky about quoting (the\n> individual keys are shell-quoted, but it insists that there is an outer\n> layer of single-quotes, even if they weren't necessary; I wouldn't be\n> opposed to making it more friendly). You can see what it produces like\n> this:\n>\n>   git -c alias.dump='!echo \"$GIT_CONFIG_PARAMETERS\"' dump\n>\n> -Peff\n"},{"id":"393517","messageId":"20200320054101.GF499858@coredump.intra.peff.net","threadId":"53029","inReplyTo":"CANri+EzrP0TeHTfjhsf=LZkwkEZU7fSRnnKN9NLga7CNow9F0Q@mail.gmail.com","subject":"Re: git makes it impossible to ignore or override global gitconfig, needs `GITCONFIGFILE`","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2020-03-20T05:41:01Z","receivedAt":"2020-03-20T05:41:05Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Mar 19, 2020 at 07:28:58PM -0700, Timothee Cour wrote:\n\n> * require passing commands (eg `git -c`) is not good either; it'd\n> require updating scripts that rely on git (this could be arbitrarily\n> complex, sometimes impossible if you just have a binary and no source\n> code access)\n\nWell, yes, that's why I suggested setting $GIT_CONFIG_PARAMETERS\ndirectly. :)\n\nThat said, I don't have any real opposition to an environment variable\nto override the user-level config location, if somebody wants to work up\na patch. A few preliminary thoughts:\n\n - there are several levels of config file, so it probably should be\n   called GIT_GLOBAL_CONFIG or something to make it clear that it\n   matches \"config --global\" (and not system or repo-level config)\n\n - we'll read user-level config from multiple sources currently:\n   ~/.gitconfig and the xdg config dir. Presumably this would override\n   them rather than add to them to be of any use.\n\n - I wondered for a moment if such a variable would need to be added to\n   local_repo_env[] to get cleared when moving between repos. But as a\n   user-level thing, it should be outside that.\n\n-Peff\n"}]}