{"thread":{"id":"27124","subject":"problem when using --cc-cmd","startedAt":"2011-04-17T22:32:12Z","lastAt":"2011-04-20T23:01:17Z","messageCount":10,"participants":["Thiago Farina","Jonathan Nieder","Joe Perches","Ævar Arnfjörð Bjarmason"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"166020","messageId":"BANLkTikdaSG_jbzaJ7UCpG5JnwneARfx3Q@mail.gmail.com","threadId":"27124","inReplyTo":null,"subject":"problem when using --cc-cmd","fromName":"Thiago Farina","fromEmail":"tfransosi@gmail.com","sentAt":"2011-04-17T22:32:12Z","receivedAt":"2011-04-17T22:32:12Z","isPatch":false,"sender":{"key":"tfransosi@gmail.com","avatar":"https://avatars.githubusercontent.com/u/970071?v=4"},"body":"Hi,\n\nI'm trying to use the --cc-cmd to get the list of people who to copy\nwhen sending a patch to linux kernel.\n\nBut when I run:\n\n$ git send-email --to linux-kernel@vger.kernel.org --cc-cmd\nscripts/get_maintainer.pl foo\n\nI'm getting some lines like:\nUse of uninitialized value $cc in string eq at\n/home/tfarina/libexec/git-core/git-send-email line 964.\n\nAny idea?\n\nThanks in advance.\n"},{"id":"166107","messageId":"20110419215239.GA22632@elie","threadId":"27124","inReplyTo":"BANLkTikdaSG_jbzaJ7UCpG5JnwneARfx3Q@mail.gmail.com","subject":"Re: problem when using --cc-cmd","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2011-04-19T21:52:56Z","receivedAt":"2011-04-19T21:52:56Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi,\n\nThiago Farina wrote:\n\n> when I run:\n>\n> $ git send-email --to linux-kernel@vger.kernel.org --cc-cmd\n> scripts/get_maintainer.pl foo\n>\n> I'm getting some lines like:\n> Use of uninitialized value $cc in string eq at\n> /home/tfarina/libexec/git-core/git-send-email line 964.\n\nYes, sounds like a bug.  Cc-ing some send-email people for tips.\n\nOn the other hand, using --cc-cmd=scripts/get_maintainer.pl does not\nsound like a great idea to me.  On one hand the output of\nget_maintainer.pl is not an unadorned address per line like --cc-cmd\nexpects.  On the other hand, at least some versions of\nget_maintainer.pl returned more addresses than are likely to be\ninterested people (by using --git by default).\n\nI think get_maintainer.pl is meant to be a starting point for tracking\ndown who might be interested in a patch and should be followed by\ncareful investigation.  (That means making sure that there is a\nreasonable number of people and the reasons given by --roles ouput\nmake sense, and maybe even glancing at some messages by them from the\nrelevant mailing list to make sure the script has not gone haywire.)\n\nHope that helps,\nJonathan\n"},{"id":"166123","messageId":"1303268630.24766.9.camel@Joe-Laptop","threadId":"27124","inReplyTo":"20110419215239.GA22632@elie","subject":"Re: problem when using --cc-cmd","fromName":"Joe Perches","fromEmail":"joe@perches.com","sentAt":"2011-04-20T03:03:50Z","receivedAt":"2011-04-20T03:03:50Z","isPatch":false,"sender":{"key":"joe@perches.com","avatar":"https://avatars.githubusercontent.com/u/13122723?v=4"},"body":"On Tue, 2011-04-19 at 16:52 -0500, Jonathan Nieder wrote:\n> Thiago Farina wrote:\n> > when I run:\n> > $ git send-email --to linux-kernel@vger.kernel.org --cc-cmd\n> > scripts/get_maintainer.pl foo\n> > I'm getting some lines like:\n> > Use of uninitialized value $cc in string eq at\n> > /home/tfarina/libexec/git-core/git-send-email line 964.\n> Yes, sounds like a bug.  Cc-ing some send-email people for tips.\n\nI haven't seen this.\n\nWhat versions of ./scripts/get_maintainer.pl and git are\nyou using?\n\n> On the other hand, using --cc-cmd=scripts/get_maintainer.pl does not\n> sound like a great idea to me.  On one hand the output of\n> get_maintainer.pl is not an unadorned address per line like --cc-cmd\n> expects.  On the other hand, at least some versions of\n> get_maintainer.pl returned more addresses than are likely to be\n> interested people (by using --git by default).\n> \n> I think get_maintainer.pl is meant to be a starting point for tracking\n> down who might be interested in a patch and should be followed by\n> careful investigation.  (That means making sure that there is a\n> reasonable number of people and the reasons given by --roles ouput\n> make sense, and maybe even glancing at some messages by them from the\n> relevant mailing list to make sure the script has not gone haywire.)\n\nJonathan is basically correct in the what he writes above.\n\nI also think git history isn't a very good mechanism to\nrely on for determining MAINTAINERS, it should only be a\nfallback to determine who should receive a copy of a patch.\n\nThat said, I use scripts/get_maintainer.pl to generate\nto's and cc's.  I do not use --git or --git-fallback\nand rely only on the MAINTAINERS file pattern matching.\n\nHere are the settings I use:\n\n$ cat ~/.gitconfig\n[sendemail]\n\tchainreplyto = false\n\tthread = false\n\tsuppresscc = self\n\ttocmd = ~/bin/to.sh\n\tcccmd = ~/bin/cc.sh\n\n$ cat ~/bin/to.sh\n#!/bin/bash\n\nopts=\"--nogit --nogit-fallback --norolestats --pattern-depth=1\"\n\nif [[ $(basename $1) =~ ^0000- ]] ; then\n    ./scripts/get_maintainer.pl --nom $opts $(dirname $1)/*\nelse\n    maint=$(./scripts/get_maintainer.pl --nol $opts $1)\n\n    if [ \"$maint\" == \"\" ] ; then\n\techo \"linux-kernel@vger.kernel.org\"\n    else\n\techo \"$maint\"\n    fi\nfi\n\n$ cat ~/bin/cc.sh\n#!/bin/bash\n\nopts=\"--nogit --nogit-fallback --norolestats\"\n\nif [[ $(basename $1) =~ ^0000- ]] ; then\n    ./scripts/get_maintainer.pl --nom $opts $(dirname $1)/*\nelse\n    ./scripts/get_maintainer.pl $opts $1\nfi\n"},{"id":"166154","messageId":"BANLkTinfbF3xyfrdgfmgHQF7RHCHk8ardw@mail.gmail.com","threadId":"27124","inReplyTo":"1303268630.24766.9.camel@Joe-Laptop","subject":"Re: problem when using --cc-cmd","fromName":"Thiago Farina","fromEmail":"tfransosi@gmail.com","sentAt":"2011-04-20T15:45:47Z","receivedAt":"2011-04-20T15:45:47Z","isPatch":false,"sender":{"key":"tfransosi@gmail.com","avatar":"https://avatars.githubusercontent.com/u/970071?v=4"},"body":"On Wed, Apr 20, 2011 at 12:03 AM, Joe Perches <joe@perches.com> wrote:\n> On Tue, 2011-04-19 at 16:52 -0500, Jonathan Nieder wrote:\n>> Thiago Farina wrote:\n>> > when I run:\n>> > $ git send-email --to linux-kernel@vger.kernel.org --cc-cmd\n>> > scripts/get_maintainer.pl foo\n>> > I'm getting some lines like:\n>> > Use of uninitialized value $cc in string eq at\n>> > /home/tfarina/libexec/git-core/git-send-email line 964.\n>> Yes, sounds like a bug.  Cc-ing some send-email people for tips.\n>\n> I haven't seen this.\n>\n> What versions of ./scripts/get_maintainer.pl and git are\n> you using?\n>\n\n$ scripts/get_maintainer.pl --version\nscripts/get_maintainer.pl 0.26\n\n$ git version\ngit version 1.7.5.rc2.5.g60e19\n\n>> On the other hand, using --cc-cmd=scripts/get_maintainer.pl does not\n>> sound like a great idea to me.  On one hand the output of\n>> get_maintainer.pl is not an unadorned address per line like --cc-cmd\n>> expects.  On the other hand, at least some versions of\n>> get_maintainer.pl returned more addresses than are likely to be\n>> interested people (by using --git by default).\n>>\n>> I think get_maintainer.pl is meant to be a starting point for tracking\n>> down who might be interested in a patch and should be followed by\n>> careful investigation.  (That means making sure that there is a\n>> reasonable number of people and the reasons given by --roles ouput\n>> make sense, and maybe even glancing at some messages by them from the\n>> relevant mailing list to make sure the script has not gone haywire.)\n>\n> Jonathan is basically correct in the what he writes above.\n>\n> I also think git history isn't a very good mechanism to\n> rely on for determining MAINTAINERS, it should only be a\n> fallback to determine who should receive a copy of a patch.\n>\n> That said, I use scripts/get_maintainer.pl to generate\n> to's and cc's.  I do not use --git or --git-fallback\n> and rely only on the MAINTAINERS file pattern matching.\n>\n> Here are the settings I use:\n>\nCool, thanks for sharing it. I'll add that to my config file.\n\n> $ cat ~/.gitconfig\n> [sendemail]\n>        chainreplyto = false\n>        thread = false\n>        suppresscc = self\n>        tocmd = ~/bin/to.sh\n>        cccmd = ~/bin/cc.sh\n>\n> $ cat ~/bin/to.sh\n> #!/bin/bash\n>\n> opts=\"--nogit --nogit-fallback --norolestats --pattern-depth=1\"\n>\n> if [[ $(basename $1) =~ ^0000- ]] ; then\n>    ./scripts/get_maintainer.pl --nom $opts $(dirname $1)/*\n> else\n>    maint=$(./scripts/get_maintainer.pl --nol $opts $1)\n>\n>    if [ \"$maint\" == \"\" ] ; then\n>        echo \"linux-kernel@vger.kernel.org\"\n>    else\n>        echo \"$maint\"\n>    fi\n> fi\n>\n> $ cat ~/bin/cc.sh\n> #!/bin/bash\n>\n> opts=\"--nogit --nogit-fallback --norolestats\"\n>\n> if [[ $(basename $1) =~ ^0000- ]] ; then\n>    ./scripts/get_maintainer.pl --nom $opts $(dirname $1)/*\n> else\n>    ./scripts/get_maintainer.pl $opts $1\n> fi\n>\n>\n>\n>\n"},{"id":"166160","messageId":"1303328900.24766.29.camel@Joe-Laptop","threadId":"27124","inReplyTo":"BANLkTinfbF3xyfrdgfmgHQF7RHCHk8ardw@mail.gmail.com","subject":"Re: problem when using --cc-cmd","fromName":"Joe Perches","fromEmail":"joe@perches.com","sentAt":"2011-04-20T19:48:20Z","receivedAt":"2011-04-20T19:48:20Z","isPatch":false,"sender":{"key":"joe@perches.com","avatar":"https://avatars.githubusercontent.com/u/13122723?v=4"},"body":"On Wed, 2011-04-20 at 12:45 -0300, Thiago Farina wrote:\n> On Wed, Apr 20, 2011 at 12:03 AM, Joe Perches <joe@perches.com> wrote:\n> > On Tue, 2011-04-19 at 16:52 -0500, Jonathan Nieder wrote:\n> >> Thiago Farina wrote:\n> >> > when I run:\n> >> > $ git send-email --to linux-kernel@vger.kernel.org --cc-cmd\n> >> > scripts/get_maintainer.pl foo\n> >> > I'm getting some lines like:\n> >> > Use of uninitialized value $cc in string eq at\n> >> > /home/tfarina/libexec/git-core/git-send-email line 964.\n> >> Yes, sounds like a bug.  Cc-ing some send-email people for tips.\n> > I haven't seen this.\n> > What versions of ./scripts/get_maintainer.pl and git are\n> > you using?\n> $ scripts/get_maintainer.pl --version\n> scripts/get_maintainer.pl 0.26\n> $ git version\n> git version 1.7.5.rc2.5.g60e19\n\nTo get this to work properly, the output of cc-cmd\n(scripts/get_maintainer.pl) must be valid email addresses.\n\nThe git send-email --help for cc-cmd says:\n\n       --cc-cmd=<command>\n           Specify a command to execute once per patch file which should\n           generate patch file specific \"Cc:\" entries. Output of this command\n           must be single email address per line. Default is the value of\n           sendemail.cccmd configuration value.\n\nYou'll need to add \"--norolestats\" to the cc-cmd if\nyou use scripts/get_maintainer.pl.\n\n$ git send-email --to linux-kernel@vger.kernel.org \\\n\t--cc-cmd \"scripts/get_maintainer.pl --norolestats\" foo\n\nI suppose you could call it a defect that the\noutput of cc-cmd isn't screened for invalid\nemail addresses but I think it's not really a\nproblem.\n"},{"id":"166162","messageId":"1303336253.24766.34.camel@Joe-Laptop","threadId":"27124","inReplyTo":"BANLkTinfbF3xyfrdgfmgHQF7RHCHk8ardw@mail.gmail.com","subject":"[RFC PATCH] git-send-email: Validate recipient_cmd (to-cmd, cc-cmd) addresses","fromName":"Joe Perches","fromEmail":"joe@perches.com","sentAt":"2011-04-20T21:50:53Z","receivedAt":"2011-04-20T21:50:53Z","isPatch":true,"sender":{"key":"joe@perches.com","avatar":"https://avatars.githubusercontent.com/u/13122723?v=4"},"body":"On Wed, 2011-04-20 at 12:45 -0300, Thiago Farina wrote:\n> On Wed, Apr 20, 2011 at 12:03 AM, Joe Perches <joe@perches.com> wrote:\n> > On Tue, 2011-04-19 at 16:52 -0500, Jonathan Nieder wrote:\n> >> Thiago Farina wrote:\n> >> > when I run:\n> >> > $ git send-email --to linux-kernel@vger.kernel.org --cc-cmd\n> >> > scripts/get_maintainer.pl foo\n> >> > I'm getting some lines like:\n> >> > Use of uninitialized value $cc in string eq at\n> >> > /home/tfarina/libexec/git-core/git-send-email line 964.\n> >> Yes, sounds like a bug.  Cc-ing some send-email people for tips.\n\nPerhaps some patch like this.\n\nValidate the address(es) returned from recipient_cmd.\nDie if the output contains an invalid address.\n\nSigned-off-by: Joe Perches <joe@perches.com>\n---\n git-send-email.perl |   18 ++++++++++++------\n 1 files changed, 12 insertions(+), 6 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 76565de..9273cf2 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -870,10 +870,14 @@ sub is_rfc2047_quoted {\n # use the simplest quoting being able to handle the recipient\n sub sanitize_address {\n \tmy ($recipient) = @_;\n-\tmy ($recipient_name, $recipient_addr) = ($recipient =~ /^(.*?)\\s*(<.*)/);\n+\tmy ($recipient_name, $recipient_addr) = ($recipient =~ /^\\s*(.*?)\\s*(<[^>]+>)/);\n \n \tif (not $recipient_name) {\n-\t\treturn $recipient;\n+\t\treturn $recipient_addr if ($recipient_addr);\n+\t\tif ($recipient =~ /^\\s*(.+\\@\\S*).*$/) {\n+\t\t\treturn $1;\n+\t\t}\n+\t\treturn \"\";\n \t}\n \n \t# if recipient_name is already quoted, do nothing\n@@ -1343,11 +1347,13 @@ sub recipients_cmd {\n \twhile (my $address = <$fh>) {\n \t\t$address =~ s/^\\s*//g;\n \t\t$address =~ s/\\s*$//g;\n-\t\t$address = sanitize_address($address);\n-\t\tnext if ($address eq $sanitized_sender and $suppress_from);\n-\t\tpush @addresses, $address;\n+\t\tmy $sanitized_address = sanitize_address($address);\n+\t\tnext if ($sanitized_address eq $sanitized_sender and $suppress_from);\n+\t\tdie \"($prefix) '$cmd' returned invalid address: '$address'\\n\"\n+\t\t\tif ($address =~ /.*${sanitized_address}.+/);\n+\t\tpush @addresses, $sanitized_address;\n \t\tprintf(\"($prefix) Adding %s: %s from: '%s'\\n\",\n-\t\t       $what, $address, $cmd) unless $quiet;\n+\t\t       $what, $sanitized_address, $cmd) unless $quiet;\n \t\t}\n \tclose $fh\n \t    or die \"($prefix) failed to close pipe to '$cmd'\";\n"},{"id":"166163","messageId":"BANLkTikuC1V1U-c0wyThOZAn6gVXr7S_cQ@mail.gmail.com","threadId":"27124","inReplyTo":"1303336253.24766.34.camel@Joe-Laptop","subject":"Re: [RFC PATCH] git-send-email: Validate recipient_cmd (to-cmd, cc-cmd) addresses","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2011-04-20T22:29:24Z","receivedAt":"2011-04-20T22:29:24Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Wed, Apr 20, 2011 at 23:50, Joe Perches <joe@perches.com> wrote:\n> +       my ($recipient_name, $recipient_addr) = ($recipient =~ /^\\s*(.*?)\\s*(<[^>]+>)/);\n\nIn Perl you can write (<.*?>) instead of (<[^>]+>)\n\n> +               if ($recipient =~ /^\\s*(.+\\@\\S*).*$/) {\n\nIf this program doesn't have some extract_emails_from_string()\nfunction already it probably should.\n"},{"id":"166164","messageId":"1303339511.24766.41.camel@Joe-Laptop","threadId":"27124","inReplyTo":"BANLkTikuC1V1U-c0wyThOZAn6gVXr7S_cQ@mail.gmail.com","subject":"Re: [RFC PATCH] git-send-email: Validate recipient_cmd (to-cmd, cc-cmd) addresses","fromName":"Joe Perches","fromEmail":"joe@perches.com","sentAt":"2011-04-20T22:45:11Z","receivedAt":"2011-04-20T22:45:11Z","isPatch":true,"sender":{"key":"joe@perches.com","avatar":"https://avatars.githubusercontent.com/u/13122723?v=4"},"body":"On Thu, 2011-04-21 at 00:29 +0200, Ævar Arnfjörð Bjarmason wrote:\n> On Wed, Apr 20, 2011 at 23:50, Joe Perches <joe@perches.com> wrote:\n> > +       my ($recipient_name, $recipient_addr) = ($recipient =~ /^\\s*(.*?)\\s*(<[^>]+>)/);\n> In Perl you can write (<.*?>) instead of (<[^>]+>)\n\nHey Ævar.  That matches <>.  Not a good email address.\n\nThis is what linux/scripts/get_maintainers.pl uses:\n\nsub parse_email {\n    my ($formatted_email) = @_;\n\n    my $name = \"\";\n    my $address = \"\";\n\n    if ($formatted_email =~ /^([^<]+)<(.+\\@.*)>.*$/) {\n\t$name = $1;\n\t$address = $2;\n    } elsif ($formatted_email =~ /^\\s*<(.+\\@\\S*)>.*$/) {\n\t$address = $1;\n    } elsif ($formatted_email =~ /^(.+\\@\\S*).*$/) {\n\t$address = $1;\n    }\n\n    $name =~ s/^\\s+|\\s+$//g;\n    $name =~ s/^\\\"|\\\"$//g;\n    $address =~ s/^\\s+|\\s+$//g;\n\n    if ($name =~ /[^\\w \\-]/i) {  \t ##has \"must quote\" chars\n\t$name =~ s/(?<!\\\\)\"/\\\\\"/g;       ##escape quotes\n\t$name = \"\\\"$name\\\"\";\n    }\n\n    return ($name, $address);\n}\n\nThere's probably some weakness in that.\n\n> If this program doesn't have some extract_emails_from_string()\n> function already it probably should.\n\nMaybe it does.  It currently uses \"sanitize_address\".\n"},{"id":"166165","messageId":"BANLkTintK1KgPWX7ycMQtVBnKi+tVj7k2Q@mail.gmail.com","threadId":"27124","inReplyTo":"1303339511.24766.41.camel@Joe-Laptop","subject":"Re: [RFC PATCH] git-send-email: Validate recipient_cmd (to-cmd, cc-cmd) addresses","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2011-04-20T22:50:51Z","receivedAt":"2011-04-20T22:50:51Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Thu, Apr 21, 2011 at 00:45, Joe Perches <joe@perches.com> wrote:\n> On Thu, 2011-04-21 at 00:29 +0200, Ævar Arnfjörð Bjarmason wrote:\n>> On Wed, Apr 20, 2011 at 23:50, Joe Perches <joe@perches.com> wrote:\n>> > +       my ($recipient_name, $recipient_addr) = ($recipient =~ /^\\s*(.*?)\\s*(<[^>]+>)/);\n>> In Perl you can write (<.*?>) instead of (<[^>]+>)\n>\n> Hey Ævar.  That matches <>.  Not a good email address.\n\nTrue, but you can use <.+?> instead.\n\nI meant that you don't need to work around the lack of non-greedy\nregex features in Perl.\n"},{"id":"166166","messageId":"1303340477.24766.43.camel@Joe-Laptop","threadId":"27124","inReplyTo":"BANLkTintK1KgPWX7ycMQtVBnKi+tVj7k2Q@mail.gmail.com","subject":"Re: [RFC PATCH] git-send-email: Validate recipient_cmd (to-cmd, cc-cmd) addresses","fromName":"Joe Perches","fromEmail":"joe@perches.com","sentAt":"2011-04-20T23:01:17Z","receivedAt":"2011-04-20T23:01:17Z","isPatch":true,"sender":{"key":"joe@perches.com","avatar":"https://avatars.githubusercontent.com/u/13122723?v=4"},"body":"On Thu, 2011-04-21 at 00:50 +0200, Ævar Arnfjörð Bjarmason wrote:\n> On Thu, Apr 21, 2011 at 00:45, Joe Perches <joe@perches.com> wrote:\n> > On Thu, 2011-04-21 at 00:29 +0200, Ævar Arnfjörð Bjarmason wrote:\n> >> On Wed, Apr 20, 2011 at 23:50, Joe Perches <joe@perches.com> wrote:\n> >> > +       my ($recipient_name, $recipient_addr) = ($recipient =~ /^\\s*(.*?)\\s*(<[^>]+>)/);\n> >> In Perl you can write (<.*?>) instead of (<[^>]+>)\n> > Hey Ævar.  That matches <>.  Not a good email address.\n> True, but you can use <.+?> instead.\n\nNope, that matches all of \"<>>\"\nI want to terminate the match on the first >.\n"}]}