threads / discuss / 14169

commit 'git-send-email: add support for TLS via Net::SMTP::SSL' causes warnings

Subject: commit 'git-send-email: add support for TLS via Net::SMTP::SSL' causes warnings

## tl;dr

4 messages between Jun 26, 2008 and Jun 26, 2008.

replies: 3people: 2as markdown or json

Kevin Ballard· Jun 26, 2008, 20:19 UTC · lore

Your recent commit to next (f6bebd1) causes warnings when no form of encryption is specified. Specifically, lines 755 and 765 reference $smtp_encryption, but when no encryption is given at all this variable is undefined.

-Kevin Ballard
-- 
Kevin Ballard
http://kevin.sb.org
kevin@sb.org
http://www.tildesoft.com
Kevin Ballard· Jun 26, 2008, 20:36 UTC · re: Kevin Ballard · lore

[PATCH] git-send-email: Fix warning triggered by f6bebd12 when no encryption is set

---
 git-send-email.perl |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index 60a6551..b93cd40 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -299,6 +299,8 @@ sub read_config {
 			$smtp_encryption = $enc;
 		} elsif (Git::config_bool(@repo, "$prefix.smtpssl")) {
 			$smtp_encryption = 'ssl';
+		} else {
+			$smtp_encryption = '';
 		}
 	}
 }
-- 
1.5.6.1.180.g7b731
Thomas Rast· Jun 26, 2008, 20:48 UTC · re: Kevin Ballard · lore

Re: commit 'git-send-email: add support for TLS via Net::SMTP::SSL' causes warnings

Kevin Ballard wrote:
> Your recent commit to next (f6bebd1) causes warnings when no form of  
> encryption is specified. Specifically, lines 755 and 765 reference  
> $smtp_encryption, but when no encryption is given at all this variable  
> is undefined.
Sorry for the oversight on my part, and thanks for the fix! :-)
- Thomas
-- 
Thomas Rast
trast@student.ethz.ch
Thomas Rast· Jun 26, 2008, 21:03 UTC · re: Thomas Rast · lore

Re: commit 'git-send-email: add support for TLS via Net::SMTP::SSL' causes warnings

I wrote:
> 
> and thanks for the fix

Well, actually at second glance your fix is wrong. Putting it in read_config() means it will be executed the first time around already, when we read the identity's settings. So with the patch, $smtp_encryption is set to '' during identity parsing, and any value set in the global [sendemail] section never takes effect.

Let's do the following instead.  Sorry for all the noise.

-- 8< -- git-send-email: prevent undefined variable warnings if no encryption is set

With the previous patch, not configuring any encryption (either on or off) would leave $smtp_encryption undefined. We simply set it to the empty string in that case.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---
 git-send-email.perl |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index 7630720..edb12c2 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -313,6 +313,9 @@ foreach my $setting (values %config_bool_settings) {
 	${$setting->[0]} = $setting->[1] unless (defined (${$setting->[0]}));
 }
 
+# 'default' encryption is none -- this only prevents a warning
+$smtp_encryption = '' unless (defined $smtp_encryption);
+
 # Set CC suppressions
 my(%suppress_cc);
 if (@suppress_cc) {
-- 
1.5.6.1.187.g35a8

← back to recent threads