{"thread":{"id":"46925","subject":"Git config multiple values","startedAt":"2017-10-06T11:10:32Z","lastAt":"2017-10-06T18:58:25Z","messageCount":6,"participants":["aleksander.baranowski","Jeff King","Jonathan Nieder","Andreas Heiduk"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"329872","messageId":"4b848032-e8b6-be67-58d9-e3fcc2c11853@yahoo.pl","threadId":"46925","inReplyTo":null,"subject":"Git config multiple values","fromName":"aleksander.baranowski","fromEmail":"aleksander.baranowski@yahoo.pl","sentAt":"2017-10-06T11:10:17Z","receivedAt":"2017-10-06T11:10:32Z","isPatch":false,"sender":{"key":"aleksander.baranowski@yahoo.pl","avatar":null},"body":"Hi,\n\nI'm currently using git version 2.14.2. There is possible to put\nmultiple values into same variable with git config.\n\nCase 1:\n# git config --global user.name Foo - returns 0\n# git config --global user.name Bar - returns 0 and replace Foo to Bar\n# git config --global user.name Foo - returns 0 and replace Bar to Foo\n\nCase 2:\n# git config --global user.name Foo - returns 0\n# git config --global user.name Foo2 Bar - returns 0 and put second name\n# cat ~/.gitconfig\n[user]\n\temail = aleksander.baranowski@yahoo.pl\n\tname = Foo\n\tname = Foo2\n# git config --global user.name Foo - return 5 and message\n\"warning: user.name has multiple values\nerror: cannot overwrite multiple values with a single value\n       Use a regexp, --add or --replace-all to change user.name.\"\n\nIt's just an opinion, but this behaviour is no consistent for me.\n\nIf it's not the bug it's a feature just let me know.\n\nBests,\nAlex\n"},{"id":"329891","messageId":"20171006143219.4bn63aoenluc77fd@sigill.intra.peff.net","threadId":"46925","inReplyTo":"4b848032-e8b6-be67-58d9-e3fcc2c11853@yahoo.pl","subject":"Re: Git config multiple values","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-10-06T14:32:20Z","receivedAt":"2017-10-06T14:32:26Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Oct 06, 2017 at 01:10:17PM +0200, aleksander.baranowski wrote:\n\n> I'm currently using git version 2.14.2. There is possible to put\n> multiple values into same variable with git config.\n\nYep, your examples should behave the same even with older versions.\n\n> Case 1:\n> # git config --global user.name Foo - returns 0\n> # git config --global user.name Bar - returns 0 and replace Foo to Bar\n> # git config --global user.name Foo - returns 0 and replace Bar to Foo\n\nThis is all as expected. You're hitting the first case in the manpage\nsynopsis here (I snipped the uninteresting options):\n\n  git config name [value [value_regex]]\n\nSo you're doing:\n\n  git config name value\n\nwhich replaces any existing key by default. You could also do:\n\n  git config --add name value\n\nto add without replacing (if you had a config key that takes multiple\nvalues).\n\n> Case 2:\n> # git config --global user.name Foo - returns 0\n> # git config --global user.name Foo2 Bar - returns 0 and put second name\n\nHere you're doing:\n\n  git config name value value_regex\n\nSo we're replacing any values which match the regex \"Bar\" (and there are\nnone), and leaving others intact. Hence after this you will have two\nuser.name values.\n\nIf you wanted a name with two strings, you'd have to quote the string\nfrom the shell to leave it as a single argument:\n\n  git config user.name \"Foo2 Bar\"\n\n> # cat ~/.gitconfig\n> [user]\n> \temail = aleksander.baranowski@yahoo.pl\n> \tname = Foo\n> \tname = Foo2\n\nRight, this is what I'd expect.\n\n> # git config --global user.name Foo - return 5 and message\n> \"warning: user.name has multiple values\n> error: cannot overwrite multiple values with a single value\n>        Use a regexp, --add or --replace-all to change user.name.\"\n\nAnd this, too (though I forgot we had such a safety check).\n\n> It's just an opinion, but this behaviour is no consistent for me.\n> \n> If it's not the bug it's a feature just let me know.\n\nIt's a feature, though I agree that git-config is rather baroque. We're\nmostly stuck with it for reasons of backwards compatibility, though.\n\n-Peff\n"},{"id":"329902","messageId":"07ab076b-e1c6-8731-4501-17459bdff005@yahoo.pl","threadId":"46925","inReplyTo":"20171006143219.4bn63aoenluc77fd@sigill.intra.peff.net","subject":"Re: Git config multiple values","fromName":"aleksander.baranowski","fromEmail":"aleksander.baranowski@yahoo.pl","sentAt":"2017-10-06T16:57:01Z","receivedAt":"2017-10-06T16:57:08Z","isPatch":false,"sender":{"key":"aleksander.baranowski@yahoo.pl","avatar":null},"body":"Hi!,\n\nThank you very much for descriptive answer.\n\nYou are absolutely right. I should read manual more carefully! Still\nit's quite odd interface. Thank you for your time.\n\nBests,\nAlex\n\n\nOn 10/06/2017 04:32 PM, Jeff King wrote:\n> On Fri, Oct 06, 2017 at 01:10:17PM +0200, aleksander.baranowski wrote:\n> \n>> I'm currently using git version 2.14.2. There is possible to put\n>> multiple values into same variable with git config.\n> \n> Yep, your examples should behave the same even with older versions.\n> \n>> Case 1:\n>> # git config --global user.name Foo - returns 0\n>> # git config --global user.name Bar - returns 0 and replace Foo to Bar\n>> # git config --global user.name Foo - returns 0 and replace Bar to Foo\n> \n> This is all as expected. You're hitting the first case in the manpage\n> synopsis here (I snipped the uninteresting options):\n> \n>   git config name [value [value_regex]]\n> \n> So you're doing:\n> \n>   git config name value\n> \n> which replaces any existing key by default. You could also do:\n> \n>   git config --add name value\n> \n> to add without replacing (if you had a config key that takes multiple\n> values).\n> \n>> Case 2:\n>> # git config --global user.name Foo - returns 0\n>> # git config --global user.name Foo2 Bar - returns 0 and put second name\n> \n> Here you're doing:\n> \n>   git config name value value_regex\n> \n> So we're replacing any values which match the regex \"Bar\" (and there are\n> none), and leaving others intact. Hence after this you will have two\n> user.name values.\n> \n> If you wanted a name with two strings, you'd have to quote the string\n> from the shell to leave it as a single argument:\n> \n>   git config user.name \"Foo2 Bar\"\n> \n>> # cat ~/.gitconfig\n>> [user]\n>> \temail = aleksander.baranowski@yahoo.pl\n>> \tname = Foo\n>> \tname = Foo2\n> \n> Right, this is what I'd expect.\n> \n>> # git config --global user.name Foo - return 5 and message\n>> \"warning: user.name has multiple values\n>> error: cannot overwrite multiple values with a single value\n>>        Use a regexp, --add or --replace-all to change user.name.\"\n> \n> And this, too (though I forgot we had such a safety check).\n> \n>> It's just an opinion, but this behaviour is no consistent for me.\n>>\n>> If it's not the bug it's a feature just let me know.\n> \n> It's a feature, though I agree that git-config is rather baroque. We're\n> mostly stuck with it for reasons of backwards compatibility, though.\n> \n> -Peff\n> \n"},{"id":"329905","messageId":"20171006172530.GV19555@aiede.mtv.corp.google.com","threadId":"46925","inReplyTo":"20171006143219.4bn63aoenluc77fd@sigill.intra.peff.net","subject":"Re: Git config multiple values","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2017-10-06T17:25:30Z","receivedAt":"2017-10-06T17:25:38Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi,\n\nJeff King wrote:\n> On Fri, Oct 06, 2017 at 01:10:17PM +0200, aleksander.baranowski wrote:\n\n>> It's just an opinion, but this behaviour is no consistent for me.\n>>\n>> If it's not the bug it's a feature just let me know.\n>\n> It's a feature, though I agree that git-config is rather baroque. We're\n> mostly stuck with it for reasons of backwards compatibility, though.\n\nThis feels like a dodge.  Can we make a list of what is baroque here,\nwith an eye to fixing it?  E.g. if we introduce a new --set option,\nthen what should its semantics be, to be more intuitive?\n\nThanks,\nJonathan\n"},{"id":"329906","messageId":"20171006172805.2udoryqelqbim5eg@sigill.intra.peff.net","threadId":"46925","inReplyTo":"20171006172530.GV19555@aiede.mtv.corp.google.com","subject":"Re: Git config multiple values","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-10-06T17:28:05Z","receivedAt":"2017-10-06T17:28:12Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Oct 06, 2017 at 10:25:30AM -0700, Jonathan Nieder wrote:\n\n> Jeff King wrote:\n> > On Fri, Oct 06, 2017 at 01:10:17PM +0200, aleksander.baranowski wrote:\n> \n> >> It's just an opinion, but this behaviour is no consistent for me.\n> >>\n> >> If it's not the bug it's a feature just let me know.\n> >\n> > It's a feature, though I agree that git-config is rather baroque. We're\n> > mostly stuck with it for reasons of backwards compatibility, though.\n> \n> This feels like a dodge.  Can we make a list of what is baroque here,\n> with an eye to fixing it?  E.g. if we introduce a new --set option,\n> then what should its semantics be, to be more intuitive?\n\nMaybe baroque isn't the right word. But changing the function of a\ncommand drastically based on the number of arguments seems like a source\nof confusion.\n\nI'm fine if somebody wants to champion a new \"--set\" option, but frankly\nI'm not sure it's worth the pain at this point.\n\n-Peff\n"},{"id":"329914","messageId":"962cbecd-4be1-f041-30e3-cc4cd19310d0@gmail.com","threadId":"46925","inReplyTo":"20171006172530.GV19555@aiede.mtv.corp.google.com","subject":"Re: Git config multiple values","fromName":"Andreas Heiduk","fromEmail":"asheiduk@gmail.com","sentAt":"2017-10-06T18:58:15Z","receivedAt":"2017-10-06T18:58:25Z","isPatch":false,"sender":{"key":"asheiduk@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9371344?v=4"},"body":"Hi,\n\nAm 06.10.2017 um 19:25 schrieb Jonathan Nieder:\n> Hi,\n> \n> Jeff King wrote:\n>> On Fri, Oct 06, 2017 at 01:10:17PM +0200, aleksander.baranowski wrote:\n> \n>>> It's just an opinion, but this behaviour is no consistent for me.\n>>>\n>>> If it's not the bug it's a feature just let me know.\n>>\n>> It's a feature, though I agree that git-config is rather baroque. We're\n>> mostly stuck with it for reasons of backwards compatibility, though.\n> \n> This feels like a dodge.  Can we make a list of what is baroque here,\n> with an eye to fixing it?  E.g. if we introduce a new --set option,\n> then what should its semantics be, to be more intuitive?\n\n\nMy reading of the manual for \n\n\tgit config --global user.name Foo2 Bar\n\nis this:\n\n       Multiple lines can be added to an option by using the --add option.\n\nDoes not apply here - no `--add` option, so no new value should be added.\n\n       If you want to update or unset an option which can occur on multiple\n       lines, a POSIX regexp value_regex needs to be given. \n\ndoes not apply: First: no \"--unset\" variant is used here leaving only \"update\".\nSecond: before that command there is only one value.\n\n       Only the existing values that match the regexp are updated or unset.\n\nSince \"Two\" does not match the previous value and `update` is the only \ndescribed case left I'd expect that the command changes nothing.I don't\nunderstand how the description allows `git config` to add a new value,\nbecause the manual talks about \"update\" twice, nothing about adding.\n\n\nConfused\n--Andreas\n"}]}