Skip to content

Commit fd499bc

Browse files
Eygene Ryabinkinspearce
authored andcommitted
git-svn: use "no warnings 'once'" to disable false-positives
Some variables coming from the Subversion's Perl bindings are used in our code only once, so the interpreter warns us about it. These warnings are false-positives, because the variables themselves are initialized in the binding's guts, that are made by SWIG. Credits to Sam Vilain for his note about "no warnings 'once'". [ew: minor formatting change] Signed-off-by: Eygene Ryabinkin <[email protected]> Acked-by: Eric Wong <[email protected]> Signed-off-by: Shawn O. Pearce <[email protected]>
1 parent 9de6d07 commit fd499bc

File tree

1 file changed

+43
-44
lines changed

1 file changed

+43
-44
lines changed

git-svn.perl

Lines changed: 43 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2303,23 +2303,31 @@ sub ssl_server_trust {
23032303
my ($cred, $realm, $failures, $cert_info, $may_save, $pool) = @_;
23042304
$may_save = undef if $_no_auth_cache;
23052305
print STDERR "Error validating server certificate for '$realm':\n";
2306-
if ($failures & $SVN::Auth::SSL::UNKNOWNCA) {
2307-
print STDERR " - The certificate is not issued by a trusted ",
2308-
"authority. Use the\n",
2309-
" fingerprint to validate the certificate manually!\n";
2310-
}
2311-
if ($failures & $SVN::Auth::SSL::CNMISMATCH) {
2312-
print STDERR " - The certificate hostname does not match.\n";
2313-
}
2314-
if ($failures & $SVN::Auth::SSL::NOTYETVALID) {
2315-
print STDERR " - The certificate is not yet valid.\n";
2316-
}
2317-
if ($failures & $SVN::Auth::SSL::EXPIRED) {
2318-
print STDERR " - The certificate has expired.\n";
2319-
}
2320-
if ($failures & $SVN::Auth::SSL::OTHER) {
2321-
print STDERR " - The certificate has an unknown error.\n";
2322-
}
2306+
{
2307+
no warnings 'once';
2308+
# All variables SVN::Auth::SSL::* are used only once,
2309+
# so we're shutting up Perl warnings about this.
2310+
if ($failures & $SVN::Auth::SSL::UNKNOWNCA) {
2311+
print STDERR " - The certificate is not issued ",
2312+
"by a trusted authority. Use the\n",
2313+
" fingerprint to validate ",
2314+
"the certificate manually!\n";
2315+
}
2316+
if ($failures & $SVN::Auth::SSL::CNMISMATCH) {
2317+
print STDERR " - The certificate hostname ",
2318+
"does not match.\n";
2319+
}
2320+
if ($failures & $SVN::Auth::SSL::NOTYETVALID) {
2321+
print STDERR " - The certificate is not yet valid.\n";
2322+
}
2323+
if ($failures & $SVN::Auth::SSL::EXPIRED) {
2324+
print STDERR " - The certificate has expired.\n";
2325+
}
2326+
if ($failures & $SVN::Auth::SSL::OTHER) {
2327+
print STDERR " - The certificate has ",
2328+
"an unknown error.\n";
2329+
}
2330+
} # no warnings 'once'
23232331
printf STDERR
23242332
"Certificate information:\n".
23252333
" - Hostname: %s\n".
@@ -2403,20 +2411,6 @@ sub _read_password {
24032411
$password;
24042412
}
24052413

2406-
package main;
2407-
2408-
{
2409-
my $kill_stupid_warnings = $SVN::Node::none.$SVN::Node::file.
2410-
$SVN::Node::dir.$SVN::Node::unknown.
2411-
$SVN::Node::none.$SVN::Node::file.
2412-
$SVN::Node::dir.$SVN::Node::unknown.
2413-
$SVN::Auth::SSL::CNMISMATCH.
2414-
$SVN::Auth::SSL::NOTYETVALID.
2415-
$SVN::Auth::SSL::EXPIRED.
2416-
$SVN::Auth::SSL::UNKNOWNCA.
2417-
$SVN::Auth::SSL::OTHER;
2418-
}
2419-
24202414
package SVN::Git::Fetcher;
24212415
use vars qw/@ISA/;
24222416
use strict;
@@ -2833,16 +2827,21 @@ sub open_or_add_dir {
28332827
if (!defined $t) {
28342828
die "$full_path not known in r$self->{r} or we have a bug!\n";
28352829
}
2836-
if ($t == $SVN::Node::none) {
2837-
return $self->add_directory($full_path, $baton,
2838-
undef, -1, $self->{pool});
2839-
} elsif ($t == $SVN::Node::dir) {
2840-
return $self->open_directory($full_path, $baton,
2841-
$self->{r}, $self->{pool});
2842-
}
2843-
print STDERR "$full_path already exists in repository at ",
2844-
"r$self->{r} and it is not a directory (",
2845-
($t == $SVN::Node::file ? 'file' : 'unknown'),"/$t)\n";
2830+
{
2831+
no warnings 'once';
2832+
# SVN::Node::none and SVN::Node::file are used only once,
2833+
# so we're shutting up Perl's warnings about them.
2834+
if ($t == $SVN::Node::none) {
2835+
return $self->add_directory($full_path, $baton,
2836+
undef, -1, $self->{pool});
2837+
} elsif ($t == $SVN::Node::dir) {
2838+
return $self->open_directory($full_path, $baton,
2839+
$self->{r}, $self->{pool});
2840+
} # no warnings 'once'
2841+
print STDERR "$full_path already exists in repository at ",
2842+
"r$self->{r} and it is not a directory (",
2843+
($t == $SVN::Node::file ? 'file' : 'unknown'),"/$t)\n";
2844+
} # no warnings 'once'
28462845
exit 1;
28472846
}
28482847

@@ -3068,11 +3067,11 @@ sub new {
30683067
my $dont_store_passwords = 1;
30693068
my $conf_t = ${$config}{'config'};
30703069
{
3070+
no warnings 'once';
30713071
# The usage of $SVN::_Core::SVN_CONFIG_* variables
30723072
# produces warnings that variables are used only once.
30733073
# I had not found the better way to shut them up, so
3074-
# warnings are disabled in this block.
3075-
no warnings;
3074+
# the warnings of type 'once' are disabled in this block.
30763075
if (SVN::_Core::svn_config_get_bool($conf_t,
30773076
$SVN::_Core::SVN_CONFIG_SECTION_AUTH,
30783077
$SVN::_Core::SVN_CONFIG_OPTION_STORE_PASSWORDS,
@@ -3087,7 +3086,7 @@ sub new {
30873086
1) == 0) {
30883087
$Git::SVN::Prompt::_no_auth_cache = 1;
30893088
}
3090-
}
3089+
} # no warnings 'once'
30913090
my $self = SVN::Ra->new(url => $url, auth => $baton,
30923091
config => $config,
30933092
pool => SVN::Pool->new,

0 commit comments

Comments
 (0)