1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-24 15:26:10 +02:00

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 <rea-git@codelabs.ru>
Acked-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
This commit is contained in:
Eygene Ryabinkin 2007-10-15 11:19:12 +04:00 committed by Shawn O. Pearce
parent 9de6d07920
commit fd499bcc9d

View File

@ -2303,23 +2303,31 @@ sub ssl_server_trust {
my ($cred, $realm, $failures, $cert_info, $may_save, $pool) = @_; my ($cred, $realm, $failures, $cert_info, $may_save, $pool) = @_;
$may_save = undef if $_no_auth_cache; $may_save = undef if $_no_auth_cache;
print STDERR "Error validating server certificate for '$realm':\n"; print STDERR "Error validating server certificate for '$realm':\n";
if ($failures & $SVN::Auth::SSL::UNKNOWNCA) { {
print STDERR " - The certificate is not issued by a trusted ", no warnings 'once';
"authority. Use the\n", # All variables SVN::Auth::SSL::* are used only once,
" fingerprint to validate the certificate manually!\n"; # so we're shutting up Perl warnings about this.
} if ($failures & $SVN::Auth::SSL::UNKNOWNCA) {
if ($failures & $SVN::Auth::SSL::CNMISMATCH) { print STDERR " - The certificate is not issued ",
print STDERR " - The certificate hostname does not match.\n"; "by a trusted authority. Use the\n",
} " fingerprint to validate ",
if ($failures & $SVN::Auth::SSL::NOTYETVALID) { "the certificate manually!\n";
print STDERR " - The certificate is not yet valid.\n"; }
} if ($failures & $SVN::Auth::SSL::CNMISMATCH) {
if ($failures & $SVN::Auth::SSL::EXPIRED) { print STDERR " - The certificate hostname ",
print STDERR " - The certificate has expired.\n"; "does not match.\n";
} }
if ($failures & $SVN::Auth::SSL::OTHER) { if ($failures & $SVN::Auth::SSL::NOTYETVALID) {
print STDERR " - The certificate has an unknown error.\n"; print STDERR " - The certificate is not yet valid.\n";
} }
if ($failures & $SVN::Auth::SSL::EXPIRED) {
print STDERR " - The certificate has expired.\n";
}
if ($failures & $SVN::Auth::SSL::OTHER) {
print STDERR " - The certificate has ",
"an unknown error.\n";
}
} # no warnings 'once'
printf STDERR printf STDERR
"Certificate information:\n". "Certificate information:\n".
" - Hostname: %s\n". " - Hostname: %s\n".
@ -2403,20 +2411,6 @@ sub _read_password {
$password; $password;
} }
package main;
{
my $kill_stupid_warnings = $SVN::Node::none.$SVN::Node::file.
$SVN::Node::dir.$SVN::Node::unknown.
$SVN::Node::none.$SVN::Node::file.
$SVN::Node::dir.$SVN::Node::unknown.
$SVN::Auth::SSL::CNMISMATCH.
$SVN::Auth::SSL::NOTYETVALID.
$SVN::Auth::SSL::EXPIRED.
$SVN::Auth::SSL::UNKNOWNCA.
$SVN::Auth::SSL::OTHER;
}
package SVN::Git::Fetcher; package SVN::Git::Fetcher;
use vars qw/@ISA/; use vars qw/@ISA/;
use strict; use strict;
@ -2833,16 +2827,21 @@ sub open_or_add_dir {
if (!defined $t) { if (!defined $t) {
die "$full_path not known in r$self->{r} or we have a bug!\n"; die "$full_path not known in r$self->{r} or we have a bug!\n";
} }
if ($t == $SVN::Node::none) { {
return $self->add_directory($full_path, $baton, no warnings 'once';
undef, -1, $self->{pool}); # SVN::Node::none and SVN::Node::file are used only once,
} elsif ($t == $SVN::Node::dir) { # so we're shutting up Perl's warnings about them.
return $self->open_directory($full_path, $baton, if ($t == $SVN::Node::none) {
$self->{r}, $self->{pool}); return $self->add_directory($full_path, $baton,
} undef, -1, $self->{pool});
print STDERR "$full_path already exists in repository at ", } elsif ($t == $SVN::Node::dir) {
"r$self->{r} and it is not a directory (", return $self->open_directory($full_path, $baton,
($t == $SVN::Node::file ? 'file' : 'unknown'),"/$t)\n"; $self->{r}, $self->{pool});
} # no warnings 'once'
print STDERR "$full_path already exists in repository at ",
"r$self->{r} and it is not a directory (",
($t == $SVN::Node::file ? 'file' : 'unknown'),"/$t)\n";
} # no warnings 'once'
exit 1; exit 1;
} }
@ -3068,11 +3067,11 @@ sub new {
my $dont_store_passwords = 1; my $dont_store_passwords = 1;
my $conf_t = ${$config}{'config'}; my $conf_t = ${$config}{'config'};
{ {
no warnings 'once';
# The usage of $SVN::_Core::SVN_CONFIG_* variables # The usage of $SVN::_Core::SVN_CONFIG_* variables
# produces warnings that variables are used only once. # produces warnings that variables are used only once.
# I had not found the better way to shut them up, so # I had not found the better way to shut them up, so
# warnings are disabled in this block. # the warnings of type 'once' are disabled in this block.
no warnings;
if (SVN::_Core::svn_config_get_bool($conf_t, if (SVN::_Core::svn_config_get_bool($conf_t,
$SVN::_Core::SVN_CONFIG_SECTION_AUTH, $SVN::_Core::SVN_CONFIG_SECTION_AUTH,
$SVN::_Core::SVN_CONFIG_OPTION_STORE_PASSWORDS, $SVN::_Core::SVN_CONFIG_OPTION_STORE_PASSWORDS,
@ -3087,7 +3086,7 @@ sub new {
1) == 0) { 1) == 0) {
$Git::SVN::Prompt::_no_auth_cache = 1; $Git::SVN::Prompt::_no_auth_cache = 1;
} }
} } # no warnings 'once'
my $self = SVN::Ra->new(url => $url, auth => $baton, my $self = SVN::Ra->new(url => $url, auth => $baton,
config => $config, config => $config,
pool => SVN::Pool->new, pool => SVN::Pool->new,