git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH v3] send-email: avoid questions when user has an ident
@ 2012-11-24 11:16 Felipe Contreras
  2012-11-26 19:35 ` Junio C Hamano
  0 siblings, 1 reply; 2+ messages in thread
From: Felipe Contreras @ 2012-11-24 11:16 UTC (permalink / raw)
  To: git
  Cc: Jeff King, Junio C Hamano, Thomas Rast, Christian Couder,
	Stephen Boyd, Ævar Arnfjörð Bjarmason,
	Felipe Contreras

Currently we keep getting questions even when the user has properly
configured his full name and password:

  Who should the emails appear to be from?
  [Felipe Contreras <felipe.contreras@gmail.com>]

And once a question pops up, other questions are turned on. This is
annoying.

The reason it's safe to avoid this question is because currently the
script fails completely when the author (or committer) is not correct,
so we won't even be reaching this point in the code.

The scenarios, and the current situation:

1) No information at all, no fully qualified domain name

  fatal: empty ident name (for <felipec@nysa.(none)>) not allowed

2) Only full name

  fatal: unable to auto-detect email address (got 'felipec@nysa.(none)')

3) Full name + fqdm

  Who should the emails appear to be from?
  [Felipe Contreras <felipec@nysa.felipec.org>]

4) Full name + EMAIL

  Who should the emails appear to be from?
  [Felipe Contreras <felipe.contreras@gmail.com>]

5) User configured
6) GIT_COMMITTER
7) GIT_AUTHOR

All these are the same as 4)

After this patch:

1) 2) won't change: git send-email would still die

4) 5) 6) 7) will change: git send-email won't ask the user

This is good, that's what we would expect, because the identity is
explicit.

3) will change: git send-email won't ask the user

This is bad, because we will try with an address such as
'felipec@nysa.felipec.org', which is most likely not what the user
wants, but the user will get warned by default (confirm=auto), and if
not, most likely the sending won't work, which the user would readily
note and fix.

The worst possible scenario is that such mail address does work, and the
user sends an email from that address unintentionally, when in fact the
user expected to correct that address in the prompt. This is a very,
very, very unlikely scenario, with many dependencies:

1) No configured user.name/user.email
2) No specified $EMAIL
3) No configured sendemail.from
4) No specified --from argument
5) A fully qualified domain name
6) A full name in the geckos field
7) A sendmail configuration that allows sending from this domain name
8) confirm=never, or
8.1) confirm configuration not hitting, or
8.2) Getting the error, not being aware of it
9) The user expecting to correct this address in the prompt

In a more likely scenario where 7) is not the case (can't send from
nysa.felipec.org), the user will simply see the mail was not sent
properly, and fix the problem.

The much more likely scenario though, is where 5) is not the case
(nysa.(none)), and git send-email will fail right away like it does now.

So the likelihood of this affecting anybody seriously is very very slim,
and the chances of this affecting somebody slightly are still very
small. The vast majority, if not all, of git users won't be affected
negatively, and a lot will benefit from this.

Tests-by: Jeff King <peff@peff.net>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---

Changes since v2:

 * Merge the relevant tests by Jeff King (the rest of the tests might be
   useful, but they belong in a separate patch series)

 git-send-email.perl   | 7 +------
 t/t9001-send-email.sh | 5 ++---
 2 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/git-send-email.perl b/git-send-email.perl
index aea66a0..503e551 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -748,16 +748,11 @@ if (!$force) {
 	}
 }
 
-my $prompting = 0;
 if (!defined $sender) {
 	$sender = $repoauthor || $repocommitter || '';
-	$sender = ask("Who should the emails appear to be from? [$sender] ",
-	              default => $sender,
-		      valid_re => qr/\@.*\./, confirm_only => 1);
-	print "Emails will be sent from: ", $sender, "\n";
-	$prompting++;
 }
 
+my $prompting = 0;
 if (!@initial_to && !defined $to_cmd) {
 	my $to = ask("Who should the emails be sent to (if any)? ",
 		     default => "",
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index 0351228..f77f68e 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -191,14 +191,13 @@ test_expect_success $PREREQ 'Show all headers' '
 
 test_expect_success $PREREQ 'Prompting works' '
 	clean_fake_sendmail &&
-	(echo "Example <from@example.com>"
-	 echo "to@example.com"
+	(echo "to@example.com"
 	 echo ""
 	) | GIT_SEND_EMAIL_NOTTY=1 git send-email \
 		--smtp-server="$(pwd)/fake.sendmail" \
 		$patches \
 		2>errors &&
-		grep "^From: Example <from@example.com>\$" msgtxt1 &&
+		grep "^From: A U Thor <author@example.com>\$" msgtxt1 &&
 		grep "^To: to@example.com\$" msgtxt1
 '
 
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v3] send-email: avoid questions when user has an ident
  2012-11-24 11:16 [PATCH v3] send-email: avoid questions when user has an ident Felipe Contreras
@ 2012-11-26 19:35 ` Junio C Hamano
  0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2012-11-26 19:35 UTC (permalink / raw)
  To: Felipe Contreras
  Cc: git, Jeff King, Thomas Rast, Christian Couder, Stephen Boyd,
	Ævar Arnfjörð Bjarmason

Felipe Contreras <felipe.contreras@gmail.com> writes:

> 3) Full name + fqdm
>
>   Who should the emails appear to be from?
>   [Felipe Contreras <felipec@nysa.felipec.org>]
> ...
> This is bad, because we will try with an address such as
> 'felipec@nysa.felipec.org', which is most likely not what the user
> wants, but the user will get warned by default (confirm=auto), and
> if not, most likely the sending won't work, which the user would
> readily note and fix.

OK, sounds sensible.

> Changes since v2:
>
>  * Merge the relevant tests by Jeff King (the rest of the tests might be
>    useful, but they belong in a separate patch series)

Thanks. Queued.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-11-26 19:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-24 11:16 [PATCH v3] send-email: avoid questions when user has an ident Felipe Contreras
2012-11-26 19:35 ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).