{"thread":{"id":"55661","subject":"Syntax for specifying a command in git config","startedAt":"2021-05-11T18:07:52Z","lastAt":"2021-05-12T03:25:19Z","messageCount":5,"participants":["Gregory Anders","Jeff King","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"424154","messageId":"YJrH8uqzapnpNEsb@gpanders.com","threadId":"55661","inReplyTo":null,"subject":"Syntax for specifying a command in git config","fromName":"Gregory Anders","fromEmail":"greg@gpanders.com","sentAt":"2021-05-11T18:07:46Z","receivedAt":"2021-05-11T18:07:52Z","isPatch":false,"sender":{"key":"greg@gpanders.com","avatar":"https://avatars.githubusercontent.com/u/8965202?v=4"},"body":"Hi all,\n\nCertain git config parameters (notably sendemail.smtpServer) expect an \nabsolute path in order to use a command. If the value begins with a / \ngit interprets it as a command; otherwise, it's interpreted it as a \nserver hostname.\n\nUsing an absolute path is not very portable, however. If I want to have \na common shared config file across multiple machines, each of which uses \na command for smtpServer (e.g. msmtp) but installed at different \nlocations, I have to modify the config file on each machine to update \nthe absolute path.\n\nObviously this is not a *huge* deal, but it is a minor annoyance. I'm \nwondering if it would be possible to add a new syntax to config options \nlike this. For example,\n\n     [sendemail]\n             smtpServer = !msmtp\n\nThe leading ! character says \"the following value is a command that \nshould be looked up in PATH\". This is congruent with alias definitions, \nwhere the leading ! means to run the following value as a command \ndirectly instead of as a git subcommand.\n\nThis also is unambiguous since server hostnames will never begin with a \n! character.\n\nI would be happy to attempt a patch at this change if it's something the \ngit maintainers are open to. And if there are any other options that \nthis would make sense for, I can add those too.\n\nThanks,\n\nGreg\n"},{"id":"424156","messageId":"YJrKJAa45mNIL+rf@coredump.intra.peff.net","threadId":"55661","inReplyTo":"YJrH8uqzapnpNEsb@gpanders.com","subject":"Re: Syntax for specifying a command in git config","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2021-05-11T18:17:08Z","receivedAt":"2021-05-11T18:17:11Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, May 11, 2021 at 12:07:46PM -0600, Gregory Anders wrote:\n\n> Certain git config parameters (notably sendemail.smtpServer) expect an\n> absolute path in order to use a command. If the value begins with a / git\n> interprets it as a command; otherwise, it's interpreted it as a server\n> hostname.\n> \n> Using an absolute path is not very portable, however. If I want to have a\n> common shared config file across multiple machines, each of which uses a\n> command for smtpServer (e.g. msmtp) but installed at different locations, I\n> have to modify the config file on each machine to update the absolute path.\n> \n> Obviously this is not a *huge* deal, but it is a minor annoyance. I'm\n> wondering if it would be possible to add a new syntax to config options like\n> this. For example,\n> \n>     [sendemail]\n>             smtpServer = !msmtp\n> \n> The leading ! character says \"the following value is a command that should\n> be looked up in PATH\". This is congruent with alias definitions, where the\n> leading ! means to run the following value as a command directly instead of\n> as a git subcommand.\n> \n> This also is unambiguous since server hostnames will never begin with a !\n> character.\n\nIMHO this is a good path forward. There's a thread from a few months ago\nwhich talks about this idea:\n\n  https://lore.kernel.org/git/YCvotU6KVruFuf9%2F@coredump.intra.peff.net/\n\nThere's some back and forth, and I'm not sure if I convinced Junio in\nthe end. But certainly a patch would be a good way to restart the\nconversation. :)\n\n-Peff\n"},{"id":"424218","messageId":"xmqqo8dgj2vk.fsf@gitster.g","threadId":"55661","inReplyTo":"YJrKJAa45mNIL+rf@coredump.intra.peff.net","subject":"Re: Syntax for specifying a command in git config","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-05-11T22:56:47Z","receivedAt":"2021-05-11T22:56:54Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n>> Obviously this is not a *huge* deal, but it is a minor annoyance. I'm\n>> wondering if it would be possible to add a new syntax to config options like\n>> this. For example,\n>> \n>>     [sendemail]\n>>             smtpServer = !msmtp\n>> \n>> The leading ! character says \"the following value is a command that should\n>> be looked up in PATH\". This is congruent with alias definitions, where the\n>> leading ! means to run the following value as a command directly instead of\n>> as a git subcommand.\n>> \n>> This also is unambiguous since server hostnames will never begin with a !\n>> character.\n>\n> IMHO this is a good path forward. There's a thread from a few months ago\n> which talks about this idea:\n>\n>   https://lore.kernel.org/git/YCvotU6KVruFuf9%2F@coredump.intra.peff.net/\n>\n> There's some back and forth, and I'm not sure if I convinced Junio in\n> the end. But certainly a patch would be a good way to restart the\n> conversation. :)\n\nThe argument is not just about configuration but applies equally to\nits command line argument \"--smtp-server=<what>\", right?  I think it\nmakes sense in both of these places.  I further wonder if we should\nallow not just a single token, but supplying an initial few arguments,\ntoo, e.g.\n\n\tgit send-email --smtp-server=\"/usr/bin/env msmtp\"\n\tgit send-email --smtp-server=\"!my-msa --emulate-sendmail\"\n\nThanks.\n\n\n\n"},{"id":"424234","messageId":"YJsiKDNbKclFU00b@coredump.intra.peff.net","threadId":"55661","inReplyTo":"xmqqo8dgj2vk.fsf@gitster.g","subject":"Re: Syntax for specifying a command in git config","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2021-05-12T00:32:40Z","receivedAt":"2021-05-12T00:32:44Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, May 12, 2021 at 07:56:47AM +0900, Junio C Hamano wrote:\n\n> > IMHO this is a good path forward. There's a thread from a few months ago\n> > which talks about this idea:\n> >\n> >   https://lore.kernel.org/git/YCvotU6KVruFuf9%2F@coredump.intra.peff.net/\n> >\n> > There's some back and forth, and I'm not sure if I convinced Junio in\n> > the end. But certainly a patch would be a good way to restart the\n> > conversation. :)\n> \n> The argument is not just about configuration but applies equally to\n> its command line argument \"--smtp-server=<what>\", right?  I think it\n> makes sense in both of these places.  I further wonder if we should\n> allow not just a single token, but supplying an initial few arguments,\n> too, e.g.\n> \n> \tgit send-email --smtp-server=\"/usr/bin/env msmtp\"\n> \tgit send-email --smtp-server=\"!my-msa --emulate-sendmail\"\n\nYes, the patch under discussion does apply to both the command-line\noption and the config option (and I agree it should).\n\nI didn't think about arguments, but you're right that may be a useful\nfeature. And if done via the shell, as brian suggested elsewhere, would\nbe more consistent with other parts of Git using \"!\" syntax.\n\nIt does make things a little weird in that:\n\n  git send-email --smtp-server='/path/to/my-sendmail foo'\n\nand\n\n  git send-email --smtp-server '!my-sendmail foo'\n\nbehave differently (the first does not work; it looks for an executable\nwith a space in the name).\n\n-Peff\n"},{"id":"424268","messageId":"xmqqtun8hbvn.fsf@gitster.g","threadId":"55661","inReplyTo":"YJsiKDNbKclFU00b@coredump.intra.peff.net","subject":"Re: Syntax for specifying a command in git config","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-05-12T03:25:16Z","receivedAt":"2021-05-12T03:25:19Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n>> \tgit send-email --smtp-server=\"/usr/bin/env msmtp\"\n>> \tgit send-email --smtp-server=\"!my-msa --emulate-sendmail\"\n>\n> Yes, the patch under discussion does apply to both the command-line\n> option and the config option (and I agree it should).\n>\n> I didn't think about arguments, but you're right that may be a useful\n> feature. And if done via the shell, as brian suggested elsewhere, would\n> be more consistent with other parts of Git using \"!\" syntax.\n\nHeh, it was my tongue-in-cheek way to say we do not need this '!'\nnew feature, as long as everybody has 'env' in /usr/bin ;-)\n\n> It does make things a little weird in that:\n>\n>   git send-email --smtp-server='/path/to/my-sendmail foo'\n>\n> and\n>\n>   git send-email --smtp-server '!my-sendmail foo'\n>\n> behave differently (the first does not work; it looks for an executable\n> with a space in the name).\n\nTrue.  Hopefully we do not have to worry about $IFS whitespaces in\nan absolute path to the mail submission program?  ... Nah, that's a\nwishful thinking.\n\nBut then nobody stops you from saying\n\n\tgit send-email --smtp-server '!/path/to/my-sendmail foo'\n\nso it probably is OK.  We can gradually deprecate the \"absolute path\"\nform and standardise on the \"!prefix\" form.\n\n"}]}