{"thread":{"id":"41894","subject":"GIT_CONFIG - what's the point?","startedAt":"2016-04-01T00:54:26Z","lastAt":"2016-04-03T20:11:55Z","messageCount":7,"participants":["Matthew Persico","Christian Couder","Jeff King","SZEDER Gábor"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"282426","messageId":"CAL20dLDQsti1qW7CrrEifPAhPp1snq9r5MgJL+mDwhLqhe6fyQ@mail.gmail.com","threadId":"41894","inReplyTo":null,"subject":"GIT_CONFIG - what's the point?","fromName":"Matthew Persico","fromEmail":"matthew.persico@gmail.com","sentAt":"2016-04-01T00:54:26Z","receivedAt":"2016-04-01T00:54:26Z","isPatch":false,"sender":{"key":"matthew.persico@gmail.com","avatar":"https://gravatar.com/avatar/6eaa354a2c41030fe66a35685ceccbf54aa492c787dd62defa30f99a9d887b65?d=mp&s=160"},"body":"Greetings.\n\nGiven the GIT_CONFIG environment variable can change 'git config'\nbehaves, it stands to reason that if GIT_CONFIG is defined, then ALL\ngit commands obey the value of GIT_CONFIG and use that file for config\ninfo.\n\nAs a test, exported GIT_CONFIG=/tmp/ohm, copied ~/.gitconfig to\n/tmp/ohm, moved ~/.gitconfig to ~/.gitconfig.hold and then tried git\nst, where 'st' is an alias for status in my config file.\n\nNo dice. git st was unrecognized.\n\nSo, what's the point of GIT_CONFIG if only git-config uses it? Or did\nI miss a step?\n\nThanks\n\n-- \nMatthew O. Persico\n"},{"id":"282447","messageId":"CAP8UFD23w_F8UtaykyY1KqE6Hee9355GZT+C29JL8EmYQCc6Yg@mail.gmail.com","threadId":"41894","inReplyTo":"CAL20dLDQsti1qW7CrrEifPAhPp1snq9r5MgJL+mDwhLqhe6fyQ@mail.gmail.com","subject":"Re: GIT_CONFIG - what's the point?","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2016-04-01T11:19:25Z","receivedAt":"2016-04-01T11:19:25Z","isPatch":false,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Fri, Apr 1, 2016 at 2:54 AM, Matthew Persico\n<matthew.persico@gmail.com> wrote:\n> Greetings.\n>\n> Given the GIT_CONFIG environment variable can change 'git config'\n> behaves, it stands to reason that if GIT_CONFIG is defined, then ALL\n> git commands obey the value of GIT_CONFIG and use that file for config\n> info.\n>\n> As a test, exported GIT_CONFIG=/tmp/ohm, copied ~/.gitconfig to\n> /tmp/ohm,\n\nIs /tmp/ohm a directory? If that is the case, then you should probably\nhave exported \"GIT_CONFIG=/tmp/ohm/.gitconfig\", as the git config doc\nsays it specifies a filename.\n"},{"id":"282456","messageId":"20160401123830.GB12019@sigill.intra.peff.net","threadId":"41894","inReplyTo":"CAL20dLDQsti1qW7CrrEifPAhPp1snq9r5MgJL+mDwhLqhe6fyQ@mail.gmail.com","subject":"Re: GIT_CONFIG - what's the point?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-04-01T12:38:30Z","receivedAt":"2016-04-01T12:38:30Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Mar 31, 2016 at 08:54:26PM -0400, Matthew Persico wrote:\n\n> So, what's the point of GIT_CONFIG if only git-config uses it? Or did\n> I miss a step?\n\nThere isn't a point to it. It's historical cruft that has been left in\nto avoid breaking older scripts. The same thing is generally better\naccomplished by using git-config's \"--file\" parameter. We should\nprobably do a better job of making that clear in the documentation.\n\nOr possibly deprecate it and eventually remove it entirely, as discussed\nin:\n\n  http://thread.gmane.org/gmane.linux.debian.devel.bugs.general/1195694/focus=257770\n\n-Peff\n"},{"id":"282462","messageId":"CAL20dLDkmjpXdmHv0MdoUEe43s9TjqrOLS2ud8HHGCF2vahWNQ@mail.gmail.com","threadId":"41894","inReplyTo":"20160401123830.GB12019@sigill.intra.peff.net","subject":"Re: GIT_CONFIG - what's the point?","fromName":"Matthew Persico","fromEmail":"matthew.persico@gmail.com","sentAt":"2016-04-01T14:31:12Z","receivedAt":"2016-04-01T14:31:12Z","isPatch":false,"sender":{"key":"matthew.persico@gmail.com","avatar":"https://gravatar.com/avatar/6eaa354a2c41030fe66a35685ceccbf54aa492c787dd62defa30f99a9d887b65?d=mp&s=160"},"body":"Let me explain my scenario. I have an nfs mounted home directory. It\nis used across multiple machines. I use different colored xterms for\neach machine. But that means that the one set of colors in my one\n.gitconfig file don't work against all my screen backgrounds. I'm\ntrying to find a way to tune the git colors per login. The ability to\nset colors in an environment variable (like most UNIX utils support)\nwould be the easiest way to do this. Failing that, I was hoping that\nby setting GIT_CONFIG per login, I could tune the color schemes with\ndifferent config files.\n\nSince that is not how GIT_CONFIG is used, I have simply decided to\nsquint where necessary, or open up a neutral colored xterm for the\ndiff, regardless of machine.\n\nYes, I could probably do diffs in many other ways, but git diff at the\ncommand line is usually the most expedient.\n\nUnless I wanted to define a GIT_CONFIG_OVER environment variable upon\nlogin, place inside it the appropriate -c<name>=<value> overrides for\ncolors, and then define a bash function git as\n\ngit () {\n   $(which git) $GIT_CONFIG_OVER \"$@\"\n   return $?\n}\n\nwhich seems silly.\n\nThanks anyway.\n\nOn Fri, Apr 1, 2016 at 8:38 AM, Jeff King <peff@peff.net> wrote:\n> On Thu, Mar 31, 2016 at 08:54:26PM -0400, Matthew Persico wrote:\n>\n>> So, what's the point of GIT_CONFIG if only git-config uses it? Or did\n>> I miss a step?\n>\n> There isn't a point to it. It's historical cruft that has been left in\n> to avoid breaking older scripts. The same thing is generally better\n> accomplished by using git-config's \"--file\" parameter. We should\n> probably do a better job of making that clear in the documentation.\n>\n> Or possibly deprecate it and eventually remove it entirely, as discussed\n> in:\n>\n>   http://thread.gmane.org/gmane.linux.debian.devel.bugs.general/1195694/focus=257770\n>\n> -Peff\n\n\n\n-- \nMatthew O. Persico\n"},{"id":"282464","messageId":"20160401145349.GA16196@sigill.intra.peff.net","threadId":"41894","inReplyTo":"CAL20dLDkmjpXdmHv0MdoUEe43s9TjqrOLS2ud8HHGCF2vahWNQ@mail.gmail.com","subject":"Re: GIT_CONFIG - what's the point?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-04-01T14:53:49Z","receivedAt":"2016-04-01T14:53:49Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Apr 01, 2016 at 10:31:12AM -0400, Matthew Persico wrote:\n\n> Let me explain my scenario. I have an nfs mounted home directory. It\n> is used across multiple machines. I use different colored xterms for\n> each machine. But that means that the one set of colors in my one\n> .gitconfig file don't work against all my screen backgrounds. I'm\n> trying to find a way to tune the git colors per login. The ability to\n> set colors in an environment variable (like most UNIX utils support)\n> would be the easiest way to do this. Failing that, I was hoping that\n> by setting GIT_CONFIG per login, I could tune the color schemes with\n> different config files.\n> \n> Since that is not how GIT_CONFIG is used, I have simply decided to\n> squint where necessary, or open up a neutral colored xterm for the\n> diff, regardless of machine.\n> \n> Yes, I could probably do diffs in many other ways, but git diff at the\n> command line is usually the most expedient.\n\nI think per-environment config is a reasonable thing to want. I can\nthink of three approaches with varying drawbacks:\n\n  1. The cleanest thing would be for git's config-include directive to\n     respect environment variables somehow. We do expand $HOME in\n\n       [include]\n       path = ~/.whatever\n\n     but only $HOME (and if you're willing to set $HOME, you can just\n     point to a different ~/.gitconfig in the first place).\n\n     So the drawback is that it doesn't currently work, and would need a\n     patch to git. ;)\n\n  2. If you don't want to change $HOME, you might be OK with changing\n     $XDG_CONFIG_HOME, which could then point to your machine-specific\n     user-level config (and could use an include to pull in the common\n     bits). See \"git help config\" for more details (particularly, I\n     think the XDG source only kicks in if you have no ~/.gitconfig, but\n     I might be misremembering the details).\n\n     The drawback is that other things besides git use $XDG_CONFIG_HOME,\n     so you might be affecting them.\n\n     You could probably come up with some elaborate scheme where each\n     host has its own $XDG_CONFIG_HOME, and you symlink in the common\n     bits. Or something. But that gets complicated pretty fast.\n\n  3. The \"git -c\" mechanism communicates config to sub-processes via the\n     $GIT_CONFIG_PARAMETERS variable. Its format and even existence are\n     undocumented, but something like this would probably do what you\n     want:\n\n       export GIT_CONFIG_PARAMETERS=\"'config1=value1' 'config2=value2'\"\n\n     The drawback is that it is definitely not officially supported.\n     However, I don't think there any plans to get rid of it (and if\n     anything, I'd suspect in the future the parser may get less picky,\n     and it might become an officially supported interface; but don't\n     quote me on that).\n\n-Peff\n"},{"id":"282488","messageId":"1459531705-31906-1-git-send-email-szeder@ira.uka.de","threadId":"41894","inReplyTo":"CAL20dLDkmjpXdmHv0MdoUEe43s9TjqrOLS2ud8HHGCF2vahWNQ@mail.gmail.com","subject":"Re: GIT_CONFIG - what's the point?","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2016-04-01T17:28:25Z","receivedAt":"2016-04-01T17:28:25Z","isPatch":false,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"> Let me explain my scenario. I have an nfs mounted home directory. It\n> is used across multiple machines. I use different colored xterms for\n> each machine. But that means that the one set of colors in my one\n> .gitconfig file don't work against all my screen backgrounds. I'm\n> trying to find a way to tune the git colors per login. The ability to\n> set colors in an environment variable (like most UNIX utils support)\n> would be the easiest way to do this. Failing that, I was hoping that\n> by setting GIT_CONFIG per login, I could tune the color schemes with\n> different config files.\n> \n> Since that is not how GIT_CONFIG is used, I have simply decided to\n> squint where necessary, or open up a neutral colored xterm for the\n> diff, regardless of machine.\n> \n> Yes, I could probably do diffs in many other ways, but git diff at the\n> command line is usually the most expedient.\n> \n> Unless I wanted to define a GIT_CONFIG_OVER environment variable upon\n> login, place inside it the appropriate -c<name>=<value> overrides for\n> colors, and then define a bash function git as\n> \n> git () {\n>    $(which git) $GIT_CONFIG_OVER \"$@\"\n>    return $?\n> }\n> \n> which seems silly.\n\nYeah, that 'return $?' at the end of the function does indeed seem\nsilly :)  (sorry, couldn't resist...)\n\nYou could use machine-specific config includes instead of that\nGIT_CONFIG_OVER environment variable.  I.e. store machine-specific\ncolor configuration in ~/.gitcolors.<machine> or something and define\nthe shell function as:\n\ngit () {\n        command git -c include.path=~/.gitcolors.$HOSTNAME \"$@\"\n}\n\nThe impact on your .bashrc would be much smaller than with the\nGIT_CONFIG_OVER approach.\nYou could even turn this into an alias, if you want.\n"},{"id":"282575","messageId":"CAL20dLAK953vmqO2E1Aw-4aDOCthJYu+xP=0GUX2DTmajLxi8A@mail.gmail.com","threadId":"41894","inReplyTo":"1459531705-31906-1-git-send-email-szeder@ira.uka.de","subject":"Re: GIT_CONFIG - what's the point?","fromName":"Matthew Persico","fromEmail":"matthew.persico@gmail.com","sentAt":"2016-04-03T20:11:55Z","receivedAt":"2016-04-03T20:11:55Z","isPatch":false,"sender":{"key":"matthew.persico@gmail.com","avatar":"https://gravatar.com/avatar/6eaa354a2c41030fe66a35685ceccbf54aa492c787dd62defa30f99a9d887b65?d=mp&s=160"},"body":"On Fri, Apr 1, 2016 at 1:28 PM, SZEDER Gábor <szeder@ira.uka.de> wrote:\n>> Let me explain my scenario. I have an nfs mounted home directory. It\n>> is used across multiple machines. I use different colored xterms for\n>> each machine. But that means that the one set of colors in my one\n>> .gitconfig file don't work against all my screen backgrounds. I'm\n>> trying to find a way to tune the git colors per login. The ability to\n>> set colors in an environment variable (like most UNIX utils support)\n>> would be the easiest way to do this. Failing that, I was hoping that\n>> by setting GIT_CONFIG per login, I could tune the color schemes with\n>> different config files.\n>>\n>> Since that is not how GIT_CONFIG is used, I have simply decided to\n>> squint where necessary, or open up a neutral colored xterm for the\n>> diff, regardless of machine.\n>>\n>> Yes, I could probably do diffs in many other ways, but git diff at the\n>> command line is usually the most expedient.\n>>\n>> Unless I wanted to define a GIT_CONFIG_OVER environment variable upon\n>> login, place inside it the appropriate -c<name>=<value> overrides for\n>> colors, and then define a bash function git as\n>>\n>> git () {\n>>    $(which git) $GIT_CONFIG_OVER \"$@\"\n>>    return $?\n>> }\n>>\n>> which seems silly.\n>\n> Yeah, that 'return $?' at the end of the function does indeed seem\n> silly :)  (sorry, couldn't resist...)\nPart OCD, part OAC. :-)\n\n>\n> You could use machine-specific config includes instead of that\n> GIT_CONFIG_OVER environment variable.  I.e. store machine-specific\n> color configuration in ~/.gitcolors.<machine> or something and define\n> the shell function as:\n>\n> git () {\n>         command git -c include.path=~/.gitcolors.$HOSTNAME \"$@\"\n> }\nBINGO! THAT was the redirection I needed! One thing I was trying to\nfigure out early one was how to put HOSTNAME-based include.path-s in\nthe .gitconfig. So I put them OUTSIDE the .gitconfig like this.\n\nMuch obliged. Next time you are in NYC - I owe you a beer!\n\n>\n> The impact on your .bashrc would be much smaller than with the\n> GIT_CONFIG_OVER approach.\n> You could even turn this into an alias, if you want.\n>\n>\n\n\n\n-- \nMatthew O. Persico\n"}]}