{"thread":{"id":"10955","subject":"[PATCH] Authenticate only once in git-send-email","startedAt":"2007-11-21T12:35:05Z","lastAt":"2007-11-22T10:07:25Z","messageCount":3,"participants":["Wincent Colaiuta","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"60498","messageId":"1195648505-21653-1-git-send-email-win@wincent.com","threadId":"10955","inReplyTo":null,"subject":"[PATCH] Authenticate only once in git-send-email","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2007-11-21T12:35:05Z","receivedAt":"2007-11-21T12:35:05Z","isPatch":true,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"When using git-send-email with SMTP authentication sending a patch series\nwould redundantly authenticate multiple times, once for each patch. In\nthe worst case, this would actually prevent the series from being sent\nbecause the server would reply with a \"5.5.0 Already Authenticated\"\nstatus code which would derail the process.\n\nThis commit teaches git-send-email to authenticate once and only once at\nthe beginning of the series.\n\nSigned-off-by: Wincent Colaiuta <win@wincent.com>\n---\n git-send-email.perl |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 9c6fa64..76baa8e 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -145,6 +145,7 @@ sub format_2822_time {\n \n my $have_email_valid = eval { require Email::Valid; 1 };\n my $smtp;\n+my $auth;\n \n sub unique_email_list(@);\n sub cleanup_compose_files();\n@@ -635,7 +636,7 @@ X-Mailer: git-send-email $gitversion\n \t\t}\n \n \t\tif ((defined $smtp_authuser) && (defined $smtp_authpass)) {\n-\t\t\t$smtp->auth( $smtp_authuser, $smtp_authpass ) or die $smtp->message;\n+\t\t\t$auth ||= $smtp->auth( $smtp_authuser, $smtp_authpass ) or die $smtp->message;\n \t\t}\n \t\t$smtp->mail( $raw_from ) or die $smtp->message;\n \t\t$smtp->to( @recipients ) or die $smtp->message;\n-- \n1.5.3.5.737.gdee1b\n"},{"id":"60620","messageId":"7vwssa7jii.fsf@gitster.siamese.dyndns.org","threadId":"10955","inReplyTo":"1195648505-21653-1-git-send-email-win@wincent.com","subject":"Re: [PATCH] Authenticate only once in git-send-email","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-22T08:48:53Z","receivedAt":"2007-11-22T08:48:53Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Wincent Colaiuta <win@wincent.com> writes:\n\n> This commit teaches git-send-email to authenticate once and only once at\n> the beginning of the series.\n\nOk.  What does $smtp->auth() return?  Presumably a true value,\nbut I do not find it the best coding style to hide a call made\nprimarily for its effects not for its return value behind a\nconditional assignment to a boolean.  Eek.\n\n>  \t\tif ((defined $smtp_authuser) && (defined $smtp_authpass)) {\n> -\t\t\t$smtp->auth( $smtp_authuser, $smtp_authpass ) or die $smtp->message;\n> +\t\t\t$auth ||= $smtp->auth( $smtp_authuser, $smtp_authpass ) or die $smtp->message;\n>  \t\t}\n\nPerhaps something along the lines of...\n\n>  \t\tif ((defined $smtp_authuser) && (defined $smtp_authpass)) {\n> \t\t\t$smtp->auth( $smtp_authuser, $smtp_authpass ) or die $smtp->message;\n> +\t\t\tundef $smtp_authpass;\n>  \t\t}\n\n... or using a separate boolean variable \"my $auth_happened\"\nmay be more appropriate.\n\nBut I am just saying this; I do not care _too_ deeply about it.\nWill apply as-is.\n \n"},{"id":"60633","messageId":"C0E02CFE-F6E6-4902-8BA1-D6AC02F1C04F@wincent.com","threadId":"10955","inReplyTo":"7vwssa7jii.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Authenticate only once in git-send-email","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2007-11-22T10:07:25Z","receivedAt":"2007-11-22T10:07:25Z","isPatch":true,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"El 22/11/2007, a las 9:48, Junio C Hamano escribió:\n\n> Wincent Colaiuta <win@wincent.com> writes:\n>\n>> This commit teaches git-send-email to authenticate once and only  \n>> once at\n>> the beginning of the series.\n>\n> Ok.  What does $smtp->auth() return?  Presumably a true value,\n\nTrue on success, false on failure.\n\n> but I do not find it the best coding style to hide a call made\n> primarily for its effects not for its return value behind a\n> conditional assignment to a boolean.  Eek.\n>\n>> \t\tif ((defined $smtp_authuser) && (defined $smtp_authpass)) {\n>> -\t\t\t$smtp->auth( $smtp_authuser, $smtp_authpass ) or die $smtp- \n>> >message;\n>> +\t\t\t$auth ||= $smtp->auth( $smtp_authuser, $smtp_authpass ) or die  \n>> $smtp->message;\n>> \t\t}\n>\n> Perhaps something along the lines of...\n>\n>> \t\tif ((defined $smtp_authuser) && (defined $smtp_authpass)) {\n>> \t\t\t$smtp->auth( $smtp_authuser, $smtp_authpass ) or die $smtp- \n>> >message;\n>> +\t\t\tundef $smtp_authpass;\n>> \t\t}\n>\n> ... or using a separate boolean variable \"my $auth_happened\"\n> may be more appropriate.\n\nOf the alternatives you suggest, I think an \"$auth_happened\" or  \n\"$auth_done\" flag is probably the nicest/cleanest.\n\n> But I am just saying this; I do not care _too_ deeply about it.\n> Will apply as-is.\n\nYes, I don't really care either. My reasoning for doing it the way I  \ndid is that I'm not much of a Perl hacker so I basically wanted to  \nmake the change as minimally invasive as possible (in this case  \nprepending \"$auth ||= \"). But above all, all that I really care about  \nis that the problem gets fixed.\n\nCheers,\nWincent\n"}]}