{"thread":{"id":"23408","subject":"Local unset override global options","startedAt":"2010-04-10T06:54:28Z","lastAt":"2010-04-12T21:07:21Z","messageCount":14,"participants":["Stefan Hajnoczi","Michael J Gruber","Junio C Hamano","Jakub Narebski","Erik Faye-Lund"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"139125","messageId":"z2kfbd9d3991004092354y21d3ac3fgf1f0675cdb5c51a8@mail.gmail.com","threadId":"23408","inReplyTo":null,"subject":"Local unset override global options","fromName":"Stefan Hajnoczi","fromEmail":"stefanha@gmail.com","sentAt":"2010-04-10T06:54:28Z","receivedAt":"2010-04-10T06:54:28Z","isPatch":false,"sender":{"key":"stefanha@gmail.com","avatar":null},"body":"I have default settings for sending email in the global git config.\nHowever, for one repo different email settings are necessary.  That\nspecific SMTP server does not want authentication, therefore smtpuser\nshould be unset.\n\nThe issue is that global smtpuser is set for the default SMTP server\nand unsetting local smtpuser results in the global smtpuser being\ninherited.  What I'd like is smtpuser to be unset for this particular\nrepo.\n\nIs there any way to \"unset override\" options locally?  If not, is this\nsomething that could and should be implemented?\n\nStefan\n"},{"id":"139313","messageId":"4BC2D61B.7050902@drmicha.warpmail.net","threadId":"23408","inReplyTo":"z2kfbd9d3991004092354y21d3ac3fgf1f0675cdb5c51a8@mail.gmail.com","subject":"Re: Local unset override global options","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2010-04-12T08:13:15Z","receivedAt":"2010-04-12T08:13:15Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Stefan Hajnoczi venit, vidit, dixit 10.04.2010 14:54:\n> I have default settings for sending email in the global git config.\n> However, for one repo different email settings are necessary.  That\n> specific SMTP server does not want authentication, therefore smtpuser\n> should be unset.\n> \n> The issue is that global smtpuser is set for the default SMTP server\n> and unsetting local smtpuser results in the global smtpuser being\n> inherited.  What I'd like is smtpuser to be unset for this particular\n> repo.\n> \n> Is there any way to \"unset override\" options locally?  If not, is this\n> something that could and should be implemented?\n> \n> Stefan\n\nhave you tried setting it to an empty value?\n\nMichael\n"},{"id":"139314","messageId":"n2ifbd9d3991004120123p7b08a8a2wee380454e9fe9a1d@mail.gmail.com","threadId":"23408","inReplyTo":"4BC2D61B.7050902@drmicha.warpmail.net","subject":"Re: Local unset override global options","fromName":"Stefan Hajnoczi","fromEmail":"stefanha@gmail.com","sentAt":"2010-04-12T08:23:00Z","receivedAt":"2010-04-12T08:23:00Z","isPatch":false,"sender":{"key":"stefanha@gmail.com","avatar":null},"body":"On Mon, Apr 12, 2010 at 9:13 AM, Michael J Gruber\n<git@drmicha.warpmail.net> wrote:\n> have you tried setting it to an empty value?\n\nYes I have tried it.  An empty string causes the SMTP auth Perl module\nto choke.  It expects a non-empty username and exits with an error.\n\nOn my system I have patched git-send-email to perform this check:\n\nif (defined $smtp_authuser and length $smtp_authuser) {\n\nThis works but feels like a hack.  I think unset override could be\nuseful for any git config option, not just sendemail.smtpuser.\n\nI'm not familiar with git internals; do you have other suggestions for\nsolving this issue?\n\nStefan\n"},{"id":"139315","messageId":"4BC2D9B5.6070400@drmicha.warpmail.net","threadId":"23408","inReplyTo":"n2ifbd9d3991004120123p7b08a8a2wee380454e9fe9a1d@mail.gmail.com","subject":"Re: Local unset override global options","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2010-04-12T08:28:37Z","receivedAt":"2010-04-12T08:28:37Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Stefan Hajnoczi venit, vidit, dixit 12.04.2010 16:23:\n> On Mon, Apr 12, 2010 at 9:13 AM, Michael J Gruber\n> <git@drmicha.warpmail.net> wrote:\n>> have you tried setting it to an empty value?\n> \n> Yes I have tried it.  An empty string causes the SMTP auth Perl module\n> to choke.  It expects a non-empty username and exits with an error.\n> \n> On my system I have patched git-send-email to perform this check:\n> \n> if (defined $smtp_authuser and length $smtp_authuser) {\n> \n> This works but feels like a hack.  I think unset override could be\n> useful for any git config option, not just sendemail.smtpuser.\n> \n> I'm not familiar with git internals; do you have other suggestions for\n> solving this issue?\n\nI don't think it's possible to ignore/unset a specific global config\nvalue right now, you can only change the path where that is looked for.\nI see two ways to go forward:\n\n- Change users of the config (such as git-send-email) to treat empty\nvalues as unset values.\n\n- Introduce a special value \"unset\" for config options.\n\nMichael\n"},{"id":"139316","messageId":"7vk4sdm5kw.fsf@alter.siamese.dyndns.org","threadId":"23408","inReplyTo":"4BC2D61B.7050902@drmicha.warpmail.net","subject":"Re: Local unset override global options","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-04-12T08:35:11Z","receivedAt":"2010-04-12T08:35:11Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael J Gruber <git@drmicha.warpmail.net> writes:\n\n> have you tried setting it to an empty value?\n\nThat sounds like a useful thing in general even outside override context.\nI however suspect that the code is not written carefully to check for\nempty string (which cannot possibly mean any valid username).\n\nPerhaps we would need something like this.\n\n git-send-email.perl |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex ce569a9..7c3f7c1 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -1043,7 +1043,7 @@ X-Mailer: git-send-email $gitversion\n \t\t\t    defined $smtp_server_port ? \"port=$smtp_server_port\" : \"\";\n \t\t}\n \n-\t\tif (defined $smtp_authuser) {\n+\t\tif (defined $smtp_authuser && $smtp_authuser ne '') {\n \n \t\t\tif (!defined $smtp_authpass) {\n \n"},{"id":"139317","messageId":"r2vfbd9d3991004120143td6f90410j60c7c002b15d5db6@mail.gmail.com","threadId":"23408","inReplyTo":"7vk4sdm5kw.fsf@alter.siamese.dyndns.org","subject":"Re: Local unset override global options","fromName":"Stefan Hajnoczi","fromEmail":"stefanha@gmail.com","sentAt":"2010-04-12T08:43:35Z","receivedAt":"2010-04-12T08:43:35Z","isPatch":false,"sender":{"key":"stefanha@gmail.com","avatar":null},"body":"On Mon, Apr 12, 2010 at 9:35 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> @@ -1043,7 +1043,7 @@ X-Mailer: git-send-email $gitversion\n>                            defined $smtp_server_port ? \"port=$smtp_server_port\" : \"\";\n>                }\n>\n> -               if (defined $smtp_authuser) {\n> +               if (defined $smtp_authuser && $smtp_authuser ne '') {\n>\n>                        if (!defined $smtp_authpass) {\n>\n\nThat would work but introduces a special case for smtpuser.  Do you\nthink users may wish to unset override other options too?\n\nStefan\n"},{"id":"139319","messageId":"m3pr25f3ye.fsf@localhost.localdomain","threadId":"23408","inReplyTo":"4BC2D9B5.6070400@drmicha.warpmail.net","subject":"Re: Local unset override global options","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-04-12T08:53:01Z","receivedAt":"2010-04-12T08:53:01Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Michael J Gruber <git@drmicha.warpmail.net> writes:\n> Stefan Hajnoczi venit, vidit, dixit 12.04.2010 16:23:\n>> On Mon, Apr 12, 2010 at 9:13 AM, Michael J Gruber\n>> <git@drmicha.warpmail.net> wrote:\n>>\n>>> have you tried setting it to an empty value?\n>> \n>> Yes I have tried it.  An empty string causes the SMTP auth Perl module\n>> to choke.  It expects a non-empty username and exits with an error.\n>> \n>> On my system I have patched git-send-email to perform this check:\n>> \n>> if (defined $smtp_authuser and length $smtp_authuser) {\n>> \n>> This works but feels like a hack.  I think unset override could be\n>> useful for any git config option, not just sendemail.smtpuser.\n>> \n>> I'm not familiar with git internals; do you have other suggestions for\n>> solving this issue?\n> \n> I don't think it's possible to ignore/unset a specific global config\n> value right now, you can only change the path where that is looked for.\n> I see two ways to go forward:\n> \n> - Change users of the config (such as git-send-email) to treat empty\n> values as unset values.\n> \n> - Introduce a special value \"unset\" for config options.\n\nHow does special case of no value, i.e.\n\n   [sendemail]\n        smtpuser\n\nrather than using empty value\n\n   [sendemail]\n        smtpuser = \"\"\n\nwork?\n\nAlso if we assume that nobody needs to have support for\nsendemail.smtpuser = 0, the condition could be simplified to\n\n  if ($smtp_authuser) {\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"139347","messageId":"7v1vekn05h.fsf@alter.siamese.dyndns.org","threadId":"23408","inReplyTo":"m3pr25f3ye.fsf@localhost.localdomain","subject":"Re: Local unset override global options","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-04-12T15:47:06Z","receivedAt":"2010-04-12T15:47:06Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> How does special case of no value, i.e.\n>\n>    [sendemail]\n>         smtpuser\n\nThat is not a special case; that is \"boolean true\".\n"},{"id":"139348","messageId":"7vtyrgllje.fsf@alter.siamese.dyndns.org","threadId":"23408","inReplyTo":"r2vfbd9d3991004120143td6f90410j60c7c002b15d5db6@mail.gmail.com","subject":"Re: Local unset override global options","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-04-12T15:48:05Z","receivedAt":"2010-04-12T15:48:05Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stefan Hajnoczi <stefanha@gmail.com> writes:\n\n> That would work but introduces a special case for smtpuser.  Do you\n> think users may wish to unset override other options too?\n\nI would indeed agree \"users may _wish_ to\", but that does not matter as\nmuch as \"users _need_ to, otherwise they cannot do X and Y and Z\".\n\nYou seem to think from the beginning of this thread that \"empty means I\ndon't want it\" is a hacky special case that is limited to this smtpuser\nvariable, but I do not share that view.  Not at all.\n\nIn fact, \"empty means I don't want it\" is a very common convention even\noutside the context of git.  Make's use of its variables is a good\nexample.  Many people's shell scripts tend to treat an empty variable and\nan unset variable the same way.  The language itself does distinguish an\nempty and an unset variable, but the colon form of ${var:-something} was\ninvented in addition to the more old fashioned ${var-something} exactly\nbecause \"empty means unset\" is so common.  Perl (run without -w/strict) is\nthe same way and undef becomes empty string by default and you need to\nactively check defined($var) if you care about the difference.  Etc. etc.\n\nThere are two rather big reasons we would want to stick to the current\nformat without introducing \"unset\".  At least we would want to try to\nuntil we find real need that justifies such a change.\n\n - We could introduce a backward incompatible change to the configuration\n   file format to say \"This variable is not set at all\", but once somebody\n   starts using the syntax in his .git/config (or worse $HOME/.gitconfig),\n   that repository cannot be used by older version of git anymore.\n\n - Also internally our variables are never \"unset\".  Behaviour of a\n   plumbing or Porcelain command implemented in C is controlled by\n   variables in C, and the contents of the configuration files overwrite\n   these variables as they are parsed from the least specific (system) to\n   the most specific.  The best you can do is \"reset to default\" (not\n   \"unset\"), and even that involves fair amount of change.\n"},{"id":"139350","messageId":"m2jfbd9d3991004120907k66951cf0y149097153fe3229a@mail.gmail.com","threadId":"23408","inReplyTo":"7vtyrgllje.fsf@alter.siamese.dyndns.org","subject":"Re: Local unset override global options","fromName":"Stefan Hajnoczi","fromEmail":"stefanha@gmail.com","sentAt":"2010-04-12T16:07:25Z","receivedAt":"2010-04-12T16:07:25Z","isPatch":false,"sender":{"key":"stefanha@gmail.com","avatar":null},"body":"On Mon, Apr 12, 2010 at 4:48 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Stefan Hajnoczi <stefanha@gmail.com> writes:\n>\n>> That would work but introduces a special case for smtpuser.  Do you\n>> think users may wish to unset override other options too?\n>\n> I would indeed agree \"users may _wish_ to\", but that does not matter as\n> much as \"users _need_ to, otherwise they cannot do X and Y and Z\".\n>\n> You seem to think from the beginning of this thread that \"empty means I\n> don't want it\" is a hacky special case that is limited to this smtpuser\n> variable, but I do not share that view.  Not at all.\n\n> There are two rather big reasons we would want to stick to the current\n> format without introducing \"unset\".  At least we would want to try to\n> until we find real need that justifies such a change.\n>\n>  - We could introduce a backward incompatible change to the configuration\n>   file format to say \"This variable is not set at all\", but once somebody\n>   starts using the syntax in his .git/config (or worse $HOME/.gitconfig),\n>   that repository cannot be used by older version of git anymore.\n>\n>  - Also internally our variables are never \"unset\".  Behaviour of a\n>   plumbing or Porcelain command implemented in C is controlled by\n>   variables in C, and the contents of the configuration files overwrite\n>   these variables as they are parsed from the least specific (system) to\n>   the most specific.  The best you can do is \"reset to default\" (not\n>   \"unset\"), and even that involves fair amount of change.\n\nKnowing that variables are never unset internally gives me a different\nperspective.  Thanks for the explanation.\n\nStefan\n"},{"id":"139359","messageId":"201004121902.08345.jnareb@gmail.com","threadId":"23408","inReplyTo":"7v1vekn05h.fsf@alter.siamese.dyndns.org","subject":"Re: Local unset override global options","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-04-12T17:02:07Z","receivedAt":"2010-04-12T17:02:07Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Junio C Hamano wrote:\n> Jakub Narebski <jnareb@gmail.com> writes:\n> \n> > How does special case of no value, i.e.\n> >\n> >    [sendemail]\n> >         smtpuser\n> \n> That is not a special case; that is \"boolean true\".\n\nWell, it is \"boolean true\" *if* git-config is used with '--bool'.\n\nIf git-send-email.perl used \"git config -l -z\" to read all its config \nvariables at once into hash, like gitweb.perl does in the \ngit_parse_project_config() subroutine, it would be able to distinguish \nbetween those the case of no value:\n\n    [sendemail]\n         smtpuser\n\n(in which case \"exists $config{'sendemail.smptuser'}\" but \"not defined \n$config{'sendemail.smtpuser'}\", and of empty value\n\n    [sendemail]\n         smtpuser = \"\"\n\n(in which case it is \"defined $config{'sendemail.smtpuser'}\" but not\ntrue \"$config{'sendemail.smtpuser'}).\n\n\nBut as git-send-email.perl uses Git::config to read config variables\none by one (equivalent to \"git config --get <variable>\"), I think that\nalso in the case of no value you would end up with $smtp_authuser\ndefined but empty (and false).\n\n\nP.S. I wonder if 'sendemail.<identity>' section and 'sendemail.identity'\ncould help with original problem...\n-- \nJakub Narebski\nPoland\n"},{"id":"139366","messageId":"7vvdbwk004.fsf@alter.siamese.dyndns.org","threadId":"23408","inReplyTo":"201004121902.08345.jnareb@gmail.com","subject":"Re: Local unset override global options","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-04-12T18:18:35Z","receivedAt":"2010-04-12T18:18:35Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> Junio C Hamano wrote:\n>> Jakub Narebski <jnareb@gmail.com> writes:\n>> \n>> > How does special case of no value, i.e.\n>> >\n>> >    [sendemail]\n>> >         smtpuser\n>> \n>> That is not a special case; that is \"boolean true\".\n>\n> Well, it is \"boolean true\" *if* git-config is used with '--bool'.\n>\n> If git-send-email.perl used \"git config -l -z\" to read all its config \n> variables at once into hash, like gitweb.perl does in the \n> git_parse_project_config() subroutine, it would be able to distinguish \n> between those the case of no value:\n>\n>     [sendemail]\n>          smtpuser\n\nIf sendemail is ever re-written in C and use git_config() API, the above\nwill become boolean.  Besides, even if you are sticking to sendemail.perl\nforever, you are still inventing another convention that \"boolean true\nmeans no I don't want it\".  And it is clearly a lot less intuitive than\n\"empty means no I don't want it\", isn't it?\n"},{"id":"139368","messageId":"p2r40aa078e1004121136xe64cf1ceq6d392402107d6985@mail.gmail.com","threadId":"23408","inReplyTo":"7vvdbwk004.fsf@alter.siamese.dyndns.org","subject":"Re: Local unset override global options","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2010-04-12T18:36:12Z","receivedAt":"2010-04-12T18:36:12Z","isPatch":false,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"On Mon, Apr 12, 2010 at 8:18 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Jakub Narebski <jnareb@gmail.com> writes:\n>\n>> Junio C Hamano wrote:\n>>> Jakub Narebski <jnareb@gmail.com> writes:\n>>>\n>>> > How does special case of no value, i.e.\n>>> >\n>>> >    [sendemail]\n>>> >         smtpuser\n>>>\n>>> That is not a special case; that is \"boolean true\".\n>>\n>> Well, it is \"boolean true\" *if* git-config is used with '--bool'.\n>>\n>> If git-send-email.perl used \"git config -l -z\" to read all its config\n>> variables at once into hash, like gitweb.perl does in the\n>> git_parse_project_config() subroutine, it would be able to distinguish\n>> between those the case of no value:\n>>\n>>     [sendemail]\n>>          smtpuser\n>\n> If sendemail is ever re-written in C and use git_config() API, the above\n> will become boolean.  Besides, even if you are sticking to sendemail.perl\n\nActually, I have a very very (very) rudimentary port of send-email in\nC. I worked on that mostly for Windows compatibility, but we already\nsolved the issue for msysGit by supplying msmtp instead, so I haven't\nbeen working at it for quite some time. It's based on an older version\nof send-email, and is incomplete in many ways (no alias-support, for\none), but most of the \"tricky\" parts are done AFAICT (SMTP with SSL if\nOpenSSL is available).\n\nIs there any interest in this?\n\nI think in the long run, it'd be beneficial for Git for Windows not to\nstrictly depend on perl, but I don't really see that happening any\ntime soon as there's just too many essential tools written in perl.\nSend-email is one of them (possibly one of the less essential tools\nfor most Windows users, though).\n\n-- \nErik \"kusma\" Faye-Lund\n"},{"id":"139371","messageId":"201004122307.22836.jnareb@gmail.com","threadId":"23408","inReplyTo":"7vvdbwk004.fsf@alter.siamese.dyndns.org","subject":"Re: Local unset override global options","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-04-12T21:07:21Z","receivedAt":"2010-04-12T21:07:21Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Junio C Hamano wrote:\n> Jakub Narebski <jnareb@gmail.com> writes:\n> \n> > Junio C Hamano wrote:\n> >> Jakub Narebski <jnareb@gmail.com> writes:\n> >> \n> >> > How does special case of no value, i.e.\n> >> >\n> >> >    [sendemail]\n> >> >         smtpuser\n> >> \n> >> That is not a special case; that is \"boolean true\".\n> >\n> > Well, it is \"boolean true\" *if* git-config is used with '--bool'.\n> >\n> > If git-send-email.perl used \"git config -l -z\" to read all its config \n> > variables at once into hash, like gitweb.perl does in the \n> > git_parse_project_config() subroutine, it would be able to distinguish \n> > between those the case of no value:\n> >\n> >     [sendemail]\n> >          smtpuser\n> \n> If sendemail is ever re-written in C and use git_config() API, the above\n> will become boolean.\n\nIsn't this only for git_config_bool and the like... oh, I see that\ngit_config_string does not consider no value case proper string value,\nand warns that it is suitable only for boolean variables:\n\n   if (!value)\n                return config_error_nonbool(var);\n\n> Besides, even if you are sticking to sendemail.perl \n> forever, you are still inventing another convention that \"boolean true\n> means no I don't want it\".  And it is clearly a lot less intuitive than\n> \"empty means no I don't want it\", isn't it?\n\nTrue, after thinking a bit about this using no value to unset is \na horrible, horrible hack.  git-send-email should be corrected to not\nonly check that there is value from config or command line option, but\nalso that it is sane (i.e. non-empty, or simply true-ish if we say\nthat smtpuser = \"0\" is not something we need to worry about supporting).\n\n\nAbout ORIGINAL problem: I think it can be done by setting different\nidentities, and just switching them using sendemail.identity; for some\nof those identities sendemail.<identity>.smtpuser can be not set.\n\n-- \nJakub Narebski\nPoland\n"}]}