{"thread":{"id":"32185","subject":"[PATCH v3] send-email: avoid questions when user has an ident","startedAt":"2012-11-24T11:16:19Z","lastAt":"2012-11-26T19:35:31Z","messageCount":2,"participants":["Felipe Contreras","Junio C Hamano"],"isPatch":true,"patchVersion":3,"patchTotal":null},"messages":[{"id":"203762","messageId":"1353755779-32548-1-git-send-email-felipe.contreras@gmail.com","threadId":"32185","inReplyTo":null,"subject":"[PATCH v3] send-email: avoid questions when user has an ident","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-11-24T11:16:19Z","receivedAt":"2012-11-24T11:16:19Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Currently we keep getting questions even when the user has properly\nconfigured his full name and password:\n\n  Who should the emails appear to be from?\n  [Felipe Contreras <felipe.contreras@gmail.com>]\n\nAnd once a question pops up, other questions are turned on. This is\nannoying.\n\nThe reason it's safe to avoid this question is because currently the\nscript fails completely when the author (or committer) is not correct,\nso we won't even be reaching this point in the code.\n\nThe scenarios, and the current situation:\n\n1) No information at all, no fully qualified domain name\n\n  fatal: empty ident name (for <felipec@nysa.(none)>) not allowed\n\n2) Only full name\n\n  fatal: unable to auto-detect email address (got 'felipec@nysa.(none)')\n\n3) Full name + fqdm\n\n  Who should the emails appear to be from?\n  [Felipe Contreras <felipec@nysa.felipec.org>]\n\n4) Full name + EMAIL\n\n  Who should the emails appear to be from?\n  [Felipe Contreras <felipe.contreras@gmail.com>]\n\n5) User configured\n6) GIT_COMMITTER\n7) GIT_AUTHOR\n\nAll these are the same as 4)\n\nAfter this patch:\n\n1) 2) won't change: git send-email would still die\n\n4) 5) 6) 7) will change: git send-email won't ask the user\n\nThis is good, that's what we would expect, because the identity is\nexplicit.\n\n3) will change: git send-email won't ask the user\n\nThis is bad, because we will try with an address such as\n'felipec@nysa.felipec.org', which is most likely not what the user\nwants, but the user will get warned by default (confirm=auto), and if\nnot, most likely the sending won't work, which the user would readily\nnote and fix.\n\nThe worst possible scenario is that such mail address does work, and the\nuser sends an email from that address unintentionally, when in fact the\nuser expected to correct that address in the prompt. This is a very,\nvery, very unlikely scenario, with many dependencies:\n\n1) No configured user.name/user.email\n2) No specified $EMAIL\n3) No configured sendemail.from\n4) No specified --from argument\n5) A fully qualified domain name\n6) A full name in the geckos field\n7) A sendmail configuration that allows sending from this domain name\n8) confirm=never, or\n8.1) confirm configuration not hitting, or\n8.2) Getting the error, not being aware of it\n9) The user expecting to correct this address in the prompt\n\nIn a more likely scenario where 7) is not the case (can't send from\nnysa.felipec.org), the user will simply see the mail was not sent\nproperly, and fix the problem.\n\nThe much more likely scenario though, is where 5) is not the case\n(nysa.(none)), and git send-email will fail right away like it does now.\n\nSo the likelihood of this affecting anybody seriously is very very slim,\nand the chances of this affecting somebody slightly are still very\nsmall. The vast majority, if not all, of git users won't be affected\nnegatively, and a lot will benefit from this.\n\nTests-by: Jeff King <peff@peff.net>\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n\nChanges since v2:\n\n * Merge the relevant tests by Jeff King (the rest of the tests might be\n   useful, but they belong in a separate patch series)\n\n git-send-email.perl   | 7 +------\n t/t9001-send-email.sh | 5 ++---\n 2 files changed, 3 insertions(+), 9 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex aea66a0..503e551 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -748,16 +748,11 @@ if (!$force) {\n \t}\n }\n \n-my $prompting = 0;\n if (!defined $sender) {\n \t$sender = $repoauthor || $repocommitter || '';\n-\t$sender = ask(\"Who should the emails appear to be from? [$sender] \",\n-\t              default => $sender,\n-\t\t      valid_re => qr/\\@.*\\./, confirm_only => 1);\n-\tprint \"Emails will be sent from: \", $sender, \"\\n\";\n-\t$prompting++;\n }\n \n+my $prompting = 0;\n if (!@initial_to && !defined $to_cmd) {\n \tmy $to = ask(\"Who should the emails be sent to (if any)? \",\n \t\t     default => \"\",\ndiff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh\nindex 0351228..f77f68e 100755\n--- a/t/t9001-send-email.sh\n+++ b/t/t9001-send-email.sh\n@@ -191,14 +191,13 @@ test_expect_success $PREREQ 'Show all headers' '\n \n test_expect_success $PREREQ 'Prompting works' '\n \tclean_fake_sendmail &&\n-\t(echo \"Example <from@example.com>\"\n-\t echo \"to@example.com\"\n+\t(echo \"to@example.com\"\n \t echo \"\"\n \t) | GIT_SEND_EMAIL_NOTTY=1 git send-email \\\n \t\t--smtp-server=\"$(pwd)/fake.sendmail\" \\\n \t\t$patches \\\n \t\t2>errors &&\n-\t\tgrep \"^From: Example <from@example.com>\\$\" msgtxt1 &&\n+\t\tgrep \"^From: A U Thor <author@example.com>\\$\" msgtxt1 &&\n \t\tgrep \"^To: to@example.com\\$\" msgtxt1\n '\n \n-- \n1.8.0\n"},{"id":"203910","messageId":"7vboekrwcc.fsf@alter.siamese.dyndns.org","threadId":"32185","inReplyTo":"1353755779-32548-1-git-send-email-felipe.contreras@gmail.com","subject":"Re: [PATCH v3] send-email: avoid questions when user has an ident","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-11-26T19:35:31Z","receivedAt":"2012-11-26T19:35:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Felipe Contreras <felipe.contreras@gmail.com> writes:\n\n> 3) Full name + fqdm\n>\n>   Who should the emails appear to be from?\n>   [Felipe Contreras <felipec@nysa.felipec.org>]\n> ...\n> This is bad, because we will try with an address such as\n> 'felipec@nysa.felipec.org', which is most likely not what the user\n> wants, but the user will get warned by default (confirm=auto), and\n> if not, most likely the sending won't work, which the user would\n> readily note and fix.\n\nOK, sounds sensible.\n\n> Changes since v2:\n>\n>  * Merge the relevant tests by Jeff King (the rest of the tests might be\n>    useful, but they belong in a separate patch series)\n\nThanks. Queued.\n"}]}