* [PATCH] Authenticate only once in git-send-email
@ 2007-11-21 12:35 Wincent Colaiuta
2007-11-22 8:48 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: Wincent Colaiuta @ 2007-11-21 12:35 UTC (permalink / raw)
To: git; +Cc: gitster, Wincent Colaiuta
When using git-send-email with SMTP authentication sending a patch series
would redundantly authenticate multiple times, once for each patch. In
the worst case, this would actually prevent the series from being sent
because the server would reply with a "5.5.0 Already Authenticated"
status code which would derail the process.
This commit teaches git-send-email to authenticate once and only once at
the beginning of the series.
Signed-off-by: Wincent Colaiuta <win@wincent.com>
---
git-send-email.perl | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index 9c6fa64..76baa8e 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -145,6 +145,7 @@ sub format_2822_time {
my $have_email_valid = eval { require Email::Valid; 1 };
my $smtp;
+my $auth;
sub unique_email_list(@);
sub cleanup_compose_files();
@@ -635,7 +636,7 @@ X-Mailer: git-send-email $gitversion
}
if ((defined $smtp_authuser) && (defined $smtp_authpass)) {
- $smtp->auth( $smtp_authuser, $smtp_authpass ) or die $smtp->message;
+ $auth ||= $smtp->auth( $smtp_authuser, $smtp_authpass ) or die $smtp->message;
}
$smtp->mail( $raw_from ) or die $smtp->message;
$smtp->to( @recipients ) or die $smtp->message;
--
1.5.3.5.737.gdee1b
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Authenticate only once in git-send-email
2007-11-21 12:35 [PATCH] Authenticate only once in git-send-email Wincent Colaiuta
@ 2007-11-22 8:48 ` Junio C Hamano
2007-11-22 10:07 ` Wincent Colaiuta
0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2007-11-22 8:48 UTC (permalink / raw)
To: Wincent Colaiuta; +Cc: git
Wincent Colaiuta <win@wincent.com> writes:
> This commit teaches git-send-email to authenticate once and only once at
> the beginning of the series.
Ok. What does $smtp->auth() return? Presumably a true value,
but I do not find it the best coding style to hide a call made
primarily for its effects not for its return value behind a
conditional assignment to a boolean. Eek.
> if ((defined $smtp_authuser) && (defined $smtp_authpass)) {
> - $smtp->auth( $smtp_authuser, $smtp_authpass ) or die $smtp->message;
> + $auth ||= $smtp->auth( $smtp_authuser, $smtp_authpass ) or die $smtp->message;
> }
Perhaps something along the lines of...
> if ((defined $smtp_authuser) && (defined $smtp_authpass)) {
> $smtp->auth( $smtp_authuser, $smtp_authpass ) or die $smtp->message;
> + undef $smtp_authpass;
> }
... or using a separate boolean variable "my $auth_happened"
may be more appropriate.
But I am just saying this; I do not care _too_ deeply about it.
Will apply as-is.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Authenticate only once in git-send-email
2007-11-22 8:48 ` Junio C Hamano
@ 2007-11-22 10:07 ` Wincent Colaiuta
0 siblings, 0 replies; 3+ messages in thread
From: Wincent Colaiuta @ 2007-11-22 10:07 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
El 22/11/2007, a las 9:48, Junio C Hamano escribió:
> Wincent Colaiuta <win@wincent.com> writes:
>
>> This commit teaches git-send-email to authenticate once and only
>> once at
>> the beginning of the series.
>
> Ok. What does $smtp->auth() return? Presumably a true value,
True on success, false on failure.
> but I do not find it the best coding style to hide a call made
> primarily for its effects not for its return value behind a
> conditional assignment to a boolean. Eek.
>
>> if ((defined $smtp_authuser) && (defined $smtp_authpass)) {
>> - $smtp->auth( $smtp_authuser, $smtp_authpass ) or die $smtp-
>> >message;
>> + $auth ||= $smtp->auth( $smtp_authuser, $smtp_authpass ) or die
>> $smtp->message;
>> }
>
> Perhaps something along the lines of...
>
>> if ((defined $smtp_authuser) && (defined $smtp_authpass)) {
>> $smtp->auth( $smtp_authuser, $smtp_authpass ) or die $smtp-
>> >message;
>> + undef $smtp_authpass;
>> }
>
> ... or using a separate boolean variable "my $auth_happened"
> may be more appropriate.
Of the alternatives you suggest, I think an "$auth_happened" or
"$auth_done" flag is probably the nicest/cleanest.
> But I am just saying this; I do not care _too_ deeply about it.
> Will apply as-is.
Yes, I don't really care either. My reasoning for doing it the way I
did is that I'm not much of a Perl hacker so I basically wanted to
make the change as minimally invasive as possible (in this case
prepending "$auth ||= "). But above all, all that I really care about
is that the problem gets fixed.
Cheers,
Wincent
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-11-22 10:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-21 12:35 [PATCH] Authenticate only once in git-send-email Wincent Colaiuta
2007-11-22 8:48 ` Junio C Hamano
2007-11-22 10:07 ` Wincent Colaiuta
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 NNTP newsgroup(s).