{"thread":{"id":"23512","subject":"Multiple user.name and user.email (possible feature request)","startedAt":"2010-04-18T09:12:38Z","lastAt":"2010-04-18T20:53:15Z","messageCount":7,"participants":["Eli Barzilay","Steven Michalske","Jeff King","Sverre Rabbelier"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"139819","messageId":"19402.52486.274010.66636@winooski.ccs.neu.edu","threadId":"23512","inReplyTo":null,"subject":"Multiple user.name and user.email (possible feature request)","fromName":"Eli Barzilay","fromEmail":"eli@barzilay.org","sentAt":"2010-04-18T09:12:38Z","receivedAt":"2010-04-18T09:12:38Z","isPatch":false,"sender":{"key":"eli@barzilay.org","avatar":"https://avatars.githubusercontent.com/u/185905?v=4"},"body":"Is there a way to have *no* default or some invalid default for the\nname/email -- something that will make git refuse to create a commit?\n\nFor example, I'd be happy if I could put this in my global config:\n\n  [user]\n    name = \"Eli Barzilay\"\n    email = \"-\"\n\nand then have git barf at me when I try to commit with these settings,\nsince I prefer being forced to set the appropriate address for each\nrepository rather than deal with the alternative confusion (or just\naccepting the limitations and always using the same name/email).\n\n[When I tried to see if it's possible I was surprised to see that git\nhappily creates commits for \"- <->\" and even \" <>\".]\n\n-- \n          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:\n                    http://barzilay.org/                   Maze is Life!\n"},{"id":"139825","messageId":"F5BFE3BD-7416-4F13-AF7F-0775E3234C92@gmail.com","threadId":"23512","inReplyTo":"19402.52486.274010.66636@winooski.ccs.neu.edu","subject":"Re: Multiple user.name and user.email (possible feature request)","fromName":"Steven Michalske","fromEmail":"smichalske@gmail.com","sentAt":"2010-04-18T18:16:34Z","receivedAt":"2010-04-18T18:16:34Z","isPatch":false,"sender":{"key":"smichalske@gmail.com","avatar":"https://gravatar.com/avatar/721f27456adc9ac84f3bb235f021a70015abb9e09222ae8622fc5579c6a203c1?d=mp&s=160"},"body":"On Apr 18, 2010, at 2:12 AM, Eli Barzilay wrote:\n\n> Is there a way to have *no* default or some invalid default for the\n> name/email -- something that will make git refuse to create a commit?\n>\n> For example, I'd be happy if I could put this in my global config:\n>\n>  [user]\n>    name = \"Eli Barzilay\"\n>    email = \"-\"\n>\n> and then have git barf at me when I try to commit with these settings,\n> since I prefer being forced to set the appropriate address for each\n> repository rather than deal with the alternative confusion (or just\n> accepting the limitations and always using the same name/email).\n\n\nEli,\n\nJust set the variable in the repository, not the global config.\n\ni.e. drop the --global flag. So, in your repository:\ngit config user.email \"that-repos-config\"\n\nI have three different email address for different repositories on my  \ncomputer.  I have my global config set with my most common address,  \nand the repositories with the less common email set locally in the  \nrepository.\n\nSteve\n"},{"id":"139831","messageId":"20100418183759.GA11366@coredump.intra.peff.net","threadId":"23512","inReplyTo":"F5BFE3BD-7416-4F13-AF7F-0775E3234C92@gmail.com","subject":"Re: Multiple user.name and user.email (possible feature request)","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-04-18T18:37:59Z","receivedAt":"2010-04-18T18:37:59Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Apr 18, 2010 at 11:16:34AM -0700, Steven Michalske wrote:\n\n> >For example, I'd be happy if I could put this in my global config:\n> >\n> > [user]\n> >   name = \"Eli Barzilay\"\n> >   email = \"-\"\n> >\n> >and then have git barf at me when I try to commit with these settings,\n> >since I prefer being forced to set the appropriate address for each\n> >repository rather than deal with the alternative confusion (or just\n> >accepting the limitations and always using the same name/email).\n> \n> Just set the variable in the repository, not the global config.\n\nI think the key is that he wants git to barf if he forgets to set the\nrepo-only config, instead of quietly using the global config.\n\nSine 1.7.0, git will complain loudly if you simply don't have your\nidentity set at all. There is no way to make it actually refuse the\ncommit, but the warning is quite gigantic and hard to miss:\n\n  $ git config --global --unset user.name\n  $ git config --global --unset user.email\n  $ git commit -m foo\n  [master 7c2a927] foo\n   Committer: Jeff King <peff@c-71-185-130-222.hsd1.va.comcast.net>\n  Your name and email address were configured automatically based\n  on your username and hostname. Please check that they are accurate.\n  You can suppress this message by setting them explicitly:\n\n      git config --global user.name Your Name\n      git config --global user.email you@example.com\n\n  If the identity used for this commit is wrong, you can fix it with:\n\n      git commit --amend --author='Your Name <you@example.com>'\n\n   1 files changed, 1 insertions(+), 0 deletions(-)\n\nSo I expect that will serve Eli's purpose.\n\n-Peff\n"},{"id":"139835","messageId":"r2wfabb9a1e1004181143o7ebe2cf1t883ee4a12ba29a24@mail.gmail.com","threadId":"23512","inReplyTo":"20100418183759.GA11366@coredump.intra.peff.net","subject":"Re: Multiple user.name and user.email (possible feature request)","fromName":"Sverre Rabbelier","fromEmail":"srabbelier@gmail.com","sentAt":"2010-04-18T18:43:11Z","receivedAt":"2010-04-18T18:43:11Z","isPatch":false,"sender":{"key":"srabbelier@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3098?v=4"},"body":"Heya,\n\nOn Sun, Apr 18, 2010 at 20:37, Jeff King <peff@peff.net> wrote:\n> So I expect that will serve Eli's purpose.\n\nIf it does not, would a pre-commit hook work? If he sets some\nrecognizable string (such as not setting it) as email and install a\nhook that barfs if it sees that?\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"139837","messageId":"20100418185519.GA14331@coredump.intra.peff.net","threadId":"23512","inReplyTo":"r2wfabb9a1e1004181143o7ebe2cf1t883ee4a12ba29a24@mail.gmail.com","subject":"Re: Multiple user.name and user.email (possible feature request)","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-04-18T18:55:19Z","receivedAt":"2010-04-18T18:55:19Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Apr 18, 2010 at 08:43:11PM +0200, Sverre Rabbelier wrote:\n\n> On Sun, Apr 18, 2010 at 20:37, Jeff King <peff@peff.net> wrote:\n> > So I expect that will serve Eli's purpose.\n> \n> If it does not, would a pre-commit hook work? If he sets some\n> recognizable string (such as not setting it) as email and install a\n> hook that barfs if it sees that?\n\nYeah, that could work. It would do what he wants, but he would have to\nhave the hook set up. Which means he either needs to remember to\nconfigure it in each repository (at which point he could just remember\nto configure his identity), or he needs to point to a special init\ntemplate directory with the hook.\n\nI think setting init.templatedir or GIT_TEMPLATE_DIR in the environment\nwould accomplish the latter.\n\n-Peff\n"},{"id":"139843","messageId":"19403.26467.273476.220670@winooski.ccs.neu.edu","threadId":"23512","inReplyTo":"F5BFE3BD-7416-4F13-AF7F-0775E3234C92@gmail.com","subject":"Re: Multiple user.name and user.email (possible feature request)","fromName":"Eli Barzilay","fromEmail":"eli@barzilay.org","sentAt":"2010-04-18T20:11:15Z","receivedAt":"2010-04-18T20:11:15Z","isPatch":false,"sender":{"key":"eli@barzilay.org","avatar":"https://avatars.githubusercontent.com/u/185905?v=4"},"body":"On Apr 18, Steven Michalske wrote:\n> \n> I have three different email address for different repositories on my  \n> computer.  I have my global config set with my most common address,  \n> and the repositories with the less common email set locally in the  \n> repository.\n\n(As already guessed) I really do want it to error instead of guessing.\nMy problem is that I'm very often checking out trees of one project\n(and starting from today that svn-checkout has been replaced by a git\nclone), and I will definitely get confused.  (It seems to me that this\nis a common source of problems, leading to much flammage.)\n\n\nOn Apr 18, Jeff King wrote:\n> \n> Sine 1.7.0, git will complain loudly if you simply don't have your\n> identity set at all. There is no way to make it actually refuse the\n> commit, but the warning is quite gigantic and hard to miss:\n> [...]\n> So I expect that will serve Eli's purpose.\n\nWell, that would get closer, but I'd really prefer if there was a\ndo-not-use-me value I could set.  But in any case, even this is not\nworking for me -- digging through my environment, I found that I have\nEMAIL set to my email, and so git guesses my name and doesn't produce\nthat huge response.\n\nWorse, if I set up\n\n  [user]\n    name = \"\"\n    email = \"\"\n\nin my ~/.gitconfig (and make sure that I don't have EMAIL set), then\ngit still guesses the values -- without any warning.\n\n\nOn Apr 18, Jeff King wrote:\n> On Sun, Apr 18, 2010 at 08:43:11PM +0200, Sverre Rabbelier wrote:\n> > \n> > If it does not, would a pre-commit hook work? If he sets some\n> > recognizable string (such as not setting it) as email and install\n> > a hook that barfs if it sees that?\n> \n> Yeah, that could work. It would do what he wants, but he would have\n> to have the hook set up. Which means he either needs to remember to\n> configure it in each repository (at which point he could just\n> remember to configure his identity), or he needs to point to a\n> special init template directory with the hook.\n> \n> I think setting init.templatedir or GIT_TEMPLATE_DIR in the\n> environment would accomplish the latter.\n\nYes, that sounds like it will work, and I'll do that.  But in general\nthis well beyond what most people would do.  If it was done as I\nsuggested (actually, how I thought it would behave), then this whole\nthing would be easy even for people who are afraid of shell\nprogramming...\n\n-- \n          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:\n                    http://barzilay.org/                   Maze is Life!\n"},{"id":"139846","messageId":"19403.28987.941803.339268@winooski.ccs.neu.edu","threadId":"23512","inReplyTo":"19403.26467.273476.220670@winooski.ccs.neu.edu","subject":"Re: Multiple user.name and user.email (possible feature request)","fromName":"Eli Barzilay","fromEmail":"eli@barzilay.org","sentAt":"2010-04-18T20:53:15Z","receivedAt":"2010-04-18T20:53:15Z","isPatch":false,"sender":{"key":"eli@barzilay.org","avatar":"https://avatars.githubusercontent.com/u/185905?v=4"},"body":"On Apr 18, Eli Barzilay wrote:\n> On Apr 18, Jeff King wrote:\n> > I think setting init.templatedir or GIT_TEMPLATE_DIR in the\n> > environment would accomplish the latter.\n> \n> Yes, that sounds like it will work, and I'll do that.\n\n... when 1.7.1 is out.  That's probably enough time for me to make a\nmistake.\n\n-- \n          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:\n                    http://barzilay.org/                   Maze is Life!\n"}]}