{"thread":{"id":"34388","subject":"Git --file doesn't override $HOME in version 1.8.1.2","startedAt":"2013-07-09T11:05:46Z","lastAt":"2013-07-09T19:24:55Z","messageCount":5,"participants":["Sarajärvi Tony","Thomas Rast","Junio C Hamano","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"222914","messageId":"C8A88C530F38AE47B22BDC434090CBB0ED26E0@IT-EXMB01-HKI.it.local","threadId":"34388","inReplyTo":null,"subject":"Git --file doesn't override $HOME in version 1.8.1.2","fromName":"Sarajärvi Tony","fromEmail":"tony.sarajarvi@digia.com","sentAt":"2013-07-09T11:05:46Z","receivedAt":"2013-07-09T11:05:46Z","isPatch":false,"sender":{"key":"tony.sarajarvi@digia.com","avatar":null},"body":"Using Ubuntu 13.04 with Git 1.8.1.2 I stumbled upon a problem using Puppet.\n\nIn Puppet we launch Git with the command: '/usr/bin/git config --file /home/qt/.gitconfig --get \"user.name\" \"Qt Continuous Integration System\"'\nHowever, puppet logs: \"fatal: unable to access '/root/.config/git/config': Permission denied\".\n\nPuppet is run as root, so HOME points to /root, but still -file should override the environment variable.\n\nIf the same command is run directly from terminal as root, it works as well.\n\nWith 1.8.3.2 the problem didn't reoccur.\n\n-Tony\n-------\nDigia, Qt\n"},{"id":"222917","messageId":"87mwpweywu.fsf@linux-k42r.v.cablecom.net","threadId":"34388","inReplyTo":"C8A88C530F38AE47B22BDC434090CBB0ED26E0@IT-EXMB01-HKI.it.local","subject":"Re: Git --file doesn't override $HOME in version 1.8.1.2","fromName":"Thomas Rast","fromEmail":"trast@inf.ethz.ch","sentAt":"2013-07-09T11:49:21Z","receivedAt":"2013-07-09T11:49:21Z","isPatch":false,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Sarajärvi Tony <Tony.Sarajarvi@digia.com> writes:\n\n> Using Ubuntu 13.04 with Git 1.8.1.2 I stumbled upon a problem using Puppet.\n>\n> In Puppet we launch Git with the command: '/usr/bin/git config --file\n> /home/qt/.gitconfig --get \"user.name\" \"Qt Continuous Integration\n> System\"'\n> However, puppet logs: \"fatal: unable to access '/root/.config/git/config': Permission denied\".\n>\n> Puppet is run as root, so HOME points to /root, but still -file should override the environment variable.\n>\n> If the same command is run directly from terminal as root, it works as well.\n\nTo elaborate (I briefly talked to Sarajärvi on IRC): this isn't about\nthe fatal error; we downgraded this to a nonfatal error in 4698c8f\n(config: allow inaccessible configuration under $HOME, 2013-04-12).\n\nRather, it's very strange that 'git config --file foo' tries to look at\nany config file other than 'foo'.  In a git repo:\n\n  $ strace git config --file fooconfig test.var 2>&1 | grep 'open.*config'\n  open(\"/home/thomas/.gitconfig\", O_RDONLY) = 3\n  open(\".git/config\", O_RDONLY)           = 3\n  open(\"/home/thomas/.gitconfig\", O_RDONLY) = 3\n  open(\".git/config\", O_RDONLY)           = 3\n  open(\"fooconfig\", O_RDONLY)             = 3\n\nI haven't looked into the code yet.  Probably it's simply following the\nusual code paths to discover a repo and read its config.  However, with\nthe --file option, it shouldn't.\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"222918","messageId":"7vmwpwvt7a.fsf@alter.siamese.dyndns.org","threadId":"34388","inReplyTo":"C8A88C530F38AE47B22BDC434090CBB0ED26E0@IT-EXMB01-HKI.it.local","subject":"Re: Git --file doesn't override $HOME in version 1.8.1.2","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-07-09T12:00:41Z","receivedAt":"2013-07-09T12:00:41Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sarajärvi Tony <Tony.Sarajarvi@digia.com> writes:\n\n> Using Ubuntu 13.04 with Git 1.8.1.2 I stumbled upon a problem using Puppet.\n>\n> In Puppet we launch Git with the command: '/usr/bin/git config --file /home/qt/.gitconfig --get \"user.name\" \"Qt Continuous Integration System\"'\n\nHmph.  What does this even mean?\n\n    git config --get user.name \"Qt CIS\"\n\nI have a feeling that the command will exit with an error status 1.\n\n> However, puppet logs: \"fatal: unable to access\n> '/root/.config/git/config': Permission denied\".\n>\n> Puppet is run as root, so HOME points to /root, but still -file\n> should override the environment variable.\n\nProbably.\n\n> If the same command is run directly from terminal as root, it works as well.\n\nI am not sure what you mean by \"works as well\".  It behaves\ndifferently and does not fail the same way?\n\n> With 1.8.3.2 the problem didn't reoccur.\n\nThat is probably due to b1c418e1 (Merge branch\n'jn/config-ignore-inaccessible' into maint, 2013-06-09)\n\nBut it is puzzling.\n\nThe \"error out upon an inaccessible configuration file in usual\nplaces\" check we had since v1.8.1.1 was meant to make sure that you\nwill not be missing a basic configuration before running any command\n(including \"git config\" itself).  As \"root\", you shouldn't even have\ntriggered the \"unable to access: Permission denined\" in the first\nplace.  There is something else going on.\n"},{"id":"222920","messageId":"C8A88C530F38AE47B22BDC434090CBB0ED276E@IT-EXMB01-HKI.it.local","threadId":"34388","inReplyTo":"7vmwpwvt7a.fsf@alter.siamese.dyndns.org","subject":"RE: Git --file doesn't override $HOME in version 1.8.1.2","fromName":"Sarajärvi Tony","fromEmail":"tony.sarajarvi@digia.com","sentAt":"2013-07-09T12:12:54Z","receivedAt":"2013-07-09T12:12:54Z","isPatch":false,"sender":{"key":"tony.sarajarvi@digia.com","avatar":null},"body":"\n\n> -----Original Message-----\n> From: Junio C Hamano [mailto:gitster@pobox.com]\n> Sent: 9. heinäkuuta 2013 15:01\n> To: Sarajärvi Tony\n> Cc: git@vger.kernel.org\n> Subject: Re: Git --file doesn't override $HOME in version 1.8.1.2\n> \n> Sarajärvi Tony <Tony.Sarajarvi@digia.com> writes:\n> \n> > Using Ubuntu 13.04 with Git 1.8.1.2 I stumbled upon a problem using Puppet.\n> >\n> > In Puppet we launch Git with the command: '/usr/bin/git config --file\n> /home/qt/.gitconfig --get \"user.name\" \"Qt Continuous Integration System\"'\n> \n> Hmph.  What does this even mean?\n> \n>     git config --get user.name \"Qt CIS\"\n\nOur puppet configuration is available for anyone here:\nhttps://qt.gitorious.org/qtqa/sysadmin/blobs/master/puppet/modules/git/manifests/config.pp\n\nWe check with 'unless' if the user.name has been set to what we expect it to be. The return value is different from Git if I typo the name.\n\nroot@dev-ubuntu1304-x64-01:~# git config --file /home/qt/.gitconfig --get user.name \"Qt Continuous Integration Systed\"\nroot@dev-ubuntu1304-x64-01:~# echo $?\n1\nroot@dev-ubuntu1304-x64-01:~# git config --file /home/qt/.gitconfig --get user.name \"Qt Continuous Integration System\"\nQt Continuous Integration System\nroot@dev-ubuntu1304-x64-01:~# echo $?\n0\n\n> \n> I have a feeling that the command will exit with an error status 1.\n> \n> > However, puppet logs: \"fatal: unable to access\n> > '/root/.config/git/config': Permission denied\".\n> >\n> > Puppet is run as root, so HOME points to /root, but still -file\n> > should override the environment variable.\n> \n> Probably.\n> \n> > If the same command is run directly from terminal as root, it works as well.\n> \n> I am not sure what you mean by \"works as well\".  It behaves\n> differently and does not fail the same way?\n> \nMust have been writing something else and changed my mind :) I was trying to say that everything works when run from the command line. The permission denied appears when running with Puppet. And Puppet is run as root. And even if Puppet was run as some other user, I still don't think that Git should be trying to use anything from /root, as we're giving it the --file parameter. As if Puppet removed the whole --file parameter altogether. But as it works with a newer or older version of Git, it can't be dropping the parameter out. Root user is the only one with HOME set to /root, so it must be getting that value from root's HOME variable.\n\n> > With 1.8.3.2 the problem didn't reoccur.\n> \n> That is probably due to b1c418e1 (Merge branch\n> 'jn/config-ignore-inaccessible' into maint, 2013-06-09)\n> \n> But it is puzzling.\n> \n> The \"error out upon an inaccessible configuration file in usual\n> places\" check we had since v1.8.1.1 was meant to make sure that you\n> will not be missing a basic configuration before running any command\n> (including \"git config\" itself).  As \"root\", you shouldn't even have\n> triggered the \"unable to access: Permission denined\" in the first\n> place.  There is something else going on.\n\nThat is also weird, agreed.\n"},{"id":"222952","messageId":"20130709192455.GC5153@sigill.intra.peff.net","threadId":"34388","inReplyTo":"87mwpweywu.fsf@linux-k42r.v.cablecom.net","subject":"Re: Git --file doesn't override $HOME in version 1.8.1.2","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2013-07-09T19:24:55Z","receivedAt":"2013-07-09T19:24:55Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Jul 09, 2013 at 01:49:21PM +0200, Thomas Rast wrote:\n\n> Rather, it's very strange that 'git config --file foo' tries to look at\n> any config file other than 'foo'.  In a git repo:\n> \n>   $ strace git config --file fooconfig test.var 2>&1 | grep 'open.*config'\n>   open(\"/home/thomas/.gitconfig\", O_RDONLY) = 3\n>   open(\".git/config\", O_RDONLY)           = 3\n>   open(\"/home/thomas/.gitconfig\", O_RDONLY) = 3\n>   open(\".git/config\", O_RDONLY)           = 3\n>   open(\"fooconfig\", O_RDONLY)             = 3\n> \n> I haven't looked into the code yet.  Probably it's simply following the\n> usual code paths to discover a repo and read its config.  However, with\n> the --file option, it shouldn't.\n\nI'm not so sure. It is (in theory) OK to read the usual config files to\nfind out _how_ git-config should behave, but then return results from a\nspecific file. The former should read the \"normal\" files, and the latter\nshould read whatever is specified by the options (\"--file\", a specific\nlevel like \"--global\", or the usual set of files).\n\nThere are probably not many config options that can affect git-config's\nbehavior. The few I can think of are:\n\n  1. core.editor should affect \"git config --edit\"\n\n  2. pager.config would auto-start a pager. I am not sure if that is a\n     sane thing to do or not.\n\n  3. In theory you could have advice.* affect git-config, but I do not\n     think any currently do.\n\n  4. Currently git-config does not read objects, but there are patches\n     proposed to do so. In that case, things like core.packedGitWindowSize\n     might be important.\n\nSo I think you could probably drop the config parsing, special-case (1),\nand ignore (2) as silly. But I think (3) and (4) show that it isn't the\nright thing to do; you will never know which config options affect\ngit-config's behavior in the future.\n\nThe real issue here is not the \"extra\" normal config parsing; it is that\nthe normal parsing does not work in some cases. And that has already\nbeen fixed by Jonathan's 4698c8f (config: allow inaccessible\nconfiguration under $HOME, 2013-04-12).\n\n-Peff\n"}]}