Skip to content

Commit 8cac13d

Browse files
felipecgitster
authored andcommitted
send-email: avoid questions when user has an ident
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 <[email protected]>] 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 <[email protected]>] 4) Full name + EMAIL Who should the emails appear to be from? [Felipe Contreras <[email protected]>] 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 '[email protected]', 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 <[email protected]> Signed-off-by: Felipe Contreras <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b0b00a3 commit 8cac13d

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

git-send-email.perl

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -753,16 +753,11 @@ sub file_declares_8bit_cte {
753753
}
754754
}
755755

756-
my $prompting = 0;
757756
if (!defined $sender) {
758757
$sender = $repoauthor || $repocommitter || '';
759-
$sender = ask("Who should the emails appear to be from? [$sender] ",
760-
default => $sender,
761-
valid_re => qr/\@.*\./, confirm_only => 1);
762-
print "Emails will be sent from: ", $sender, "\n";
763-
$prompting++;
764758
}
765759

760+
my $prompting = 0;
766761
if (!@initial_to && !defined $to_cmd) {
767762
my $to = ask("Who should the emails be sent to (if any)? ",
768763
default => "",

t/t9001-send-email.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,13 @@ test_expect_success $PREREQ 'Show all headers' '
191191

192192
test_expect_success $PREREQ 'Prompting works' '
193193
clean_fake_sendmail &&
194-
(echo "Example <[email protected]>"
195-
194+
196195
echo ""
197196
) | GIT_SEND_EMAIL_NOTTY=1 git send-email \
198197
--smtp-server="$(pwd)/fake.sendmail" \
199198
$patches \
200199
2>errors &&
201-
grep "^From: Example <from@example.com>\$" msgtxt1 &&
200+
grep "^From: A U Thor <author@example.com>\$" msgtxt1 &&
202201
grep "^To: [email protected]\$" msgtxt1
203202
'
204203

0 commit comments

Comments
 (0)