{"thread":{"id":"10287","subject":"[PATCH] git-svn: use \"no warnings 'once'\" to disable false-positives","startedAt":"2007-10-15T07:19:12Z","lastAt":"2007-10-16T16:50:25Z","messageCount":3,"participants":["Eygene Ryabinkin","Eric Wong"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"55825","messageId":"20071015071912.GG984@void.codelabs.ru","threadId":"10287","inReplyTo":null,"subject":"[PATCH] git-svn: use \"no warnings 'once'\" to disable false-positives","fromName":"Eygene Ryabinkin","fromEmail":"rea-git@codelabs.ru","sentAt":"2007-10-15T07:19:12Z","receivedAt":"2007-10-15T07:19:12Z","isPatch":true,"sender":{"key":"rea-git@codelabs.ru","avatar":null},"body":"Some variables coming from the Subversion's Perl bindings are used\nin our code only once, so the interpreter warns us about it.  These\nwarnings are false-positives, because the variables themselves are\ninitialized in the binding's guts, that are made by SWIG.\n\nCredits to Sam Vilain for his note about \"no warnings 'once'\".\n\nSigned-off-by: Eygene Ryabinkin <rea-git@codelabs.ru>\n---\n git-svn.perl |   86 +++++++++++++++++++++++++++------------------------------\n 1 files changed, 41 insertions(+), 45 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex f7ef421..39a70bf 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -2293,23 +2293,30 @@ sub ssl_server_trust {\n \tmy ($cred, $realm, $failures, $cert_info, $may_save, $pool) = @_;\n \t$may_save = undef if $_no_auth_cache;\n \tprint STDERR \"Error validating server certificate for '$realm':\\n\";\n-\tif ($failures & $SVN::Auth::SSL::UNKNOWNCA) {\n-\t\tprint STDERR \" - The certificate is not issued by a trusted \",\n-\t\t      \"authority. Use the\\n\",\n-\t              \"   fingerprint to validate the certificate manually!\\n\";\n-\t}\n-\tif ($failures & $SVN::Auth::SSL::CNMISMATCH) {\n-\t\tprint STDERR \" - The certificate hostname does not match.\\n\";\n-\t}\n-\tif ($failures & $SVN::Auth::SSL::NOTYETVALID) {\n-\t\tprint STDERR \" - The certificate is not yet valid.\\n\";\n-\t}\n-\tif ($failures & $SVN::Auth::SSL::EXPIRED) {\n-\t\tprint STDERR \" - The certificate has expired.\\n\";\n-\t}\n-\tif ($failures & $SVN::Auth::SSL::OTHER) {\n-\t\tprint STDERR \" - The certificate has an unknown error.\\n\";\n-\t}\n+\t{ no warnings 'once';\n+\t\t# All variables SVN::Auth::SSL::* are used only once,\n+\t\t# so we're shutting up Perl warnings about this.\n+\t\tif ($failures & $SVN::Auth::SSL::UNKNOWNCA) {\n+\t\t\tprint STDERR \" - The certificate is not issued \",\n+\t\t\t    \"by a trusted authority. Use the\\n\",\n+\t\t\t    \"   fingerprint to validate \",\n+\t\t\t    \"the certificate manually!\\n\";\n+\t\t}\n+\t\tif ($failures & $SVN::Auth::SSL::CNMISMATCH) {\n+\t\t\tprint STDERR \" - The certificate hostname \",\n+\t\t\t    \"does not match.\\n\";\n+\t\t}\n+\t\tif ($failures & $SVN::Auth::SSL::NOTYETVALID) {\n+\t\t\tprint STDERR \" - The certificate is not yet valid.\\n\";\n+\t\t}\n+\t\tif ($failures & $SVN::Auth::SSL::EXPIRED) {\n+\t\t\tprint STDERR \" - The certificate has expired.\\n\";\n+\t\t}\n+\t\tif ($failures & $SVN::Auth::SSL::OTHER) {\n+\t\t\tprint STDERR \" - The certificate has \",\n+\t\t\t    \"an unknown error.\\n\";\n+\t\t}\n+\t} # no warnings 'once'\n \tprintf STDERR\n \t        \"Certificate information:\\n\".\n \t        \" - Hostname: %s\\n\".\n@@ -2393,20 +2400,6 @@ sub _read_password {\n \t$password;\n }\n \n-package main;\n-\n-{\n-\tmy $kill_stupid_warnings = $SVN::Node::none.$SVN::Node::file.\n-\t\t\t\t$SVN::Node::dir.$SVN::Node::unknown.\n-\t\t\t\t$SVN::Node::none.$SVN::Node::file.\n-\t\t\t\t$SVN::Node::dir.$SVN::Node::unknown.\n-\t\t\t\t$SVN::Auth::SSL::CNMISMATCH.\n-\t\t\t\t$SVN::Auth::SSL::NOTYETVALID.\n-\t\t\t\t$SVN::Auth::SSL::EXPIRED.\n-\t\t\t\t$SVN::Auth::SSL::UNKNOWNCA.\n-\t\t\t\t$SVN::Auth::SSL::OTHER;\n-}\n-\n package SVN::Git::Fetcher;\n use vars qw/@ISA/;\n use strict;\n@@ -2823,16 +2816,20 @@ sub open_or_add_dir {\n \tif (!defined $t) {\n \t\tdie \"$full_path not known in r$self->{r} or we have a bug!\\n\";\n \t}\n-\tif ($t == $SVN::Node::none) {\n-\t\treturn $self->add_directory($full_path, $baton,\n-\t\t\t\t\t\tundef, -1, $self->{pool});\n-\t} elsif ($t == $SVN::Node::dir) {\n-\t\treturn $self->open_directory($full_path, $baton,\n-\t\t\t\t\t\t$self->{r}, $self->{pool});\n-\t}\n-\tprint STDERR \"$full_path already exists in repository at \",\n-\t\t\"r$self->{r} and it is not a directory (\",\n-\t\t($t == $SVN::Node::file ? 'file' : 'unknown'),\"/$t)\\n\";\n+\t{ no warnings 'once';\n+\t\t# SVN::Node::none and SVN::Node::file are used only once,\n+\t\t# so we're shutting up Perl's warnings about them.\n+\t\tif ($t == $SVN::Node::none) {\n+\t\t\treturn $self->add_directory($full_path, $baton,\n+\t\t\t    undef, -1, $self->{pool});\n+\t\t} elsif ($t == $SVN::Node::dir) {\n+\t\t\treturn $self->open_directory($full_path, $baton,\n+\t\t\t    $self->{r}, $self->{pool});\n+\t\t} # no warnings 'once'\n+\t\tprint STDERR \"$full_path already exists in repository at \",\n+\t\t    \"r$self->{r} and it is not a directory (\",\n+\t\t    ($t == $SVN::Node::file ? 'file' : 'unknown'),\"/$t)\\n\";\n+\t} # no warnings 'once'\n \texit 1;\n }\n \n@@ -3053,12 +3050,11 @@ sub new {\n \t$RA = undef;\n \tmy $dont_store_passwords = 1;\n \tmy $conf_t = ${$config}{'config'};\n-\t{\n+\t{ no warnings 'once';\n \t\t# The usage of $SVN::_Core::SVN_CONFIG_* variables\n \t\t# produces warnings that variables are used only once.\n \t\t# I had not found the better way to shut them up, so\n-\t\t# warnings are disabled in this block.\n-\t\tno warnings;\n+\t\t# the warnings of type 'once' are disabled in this block.\n \t\tif (SVN::_Core::svn_config_get_bool($conf_t,\n \t\t    $SVN::_Core::SVN_CONFIG_SECTION_AUTH,\n \t\t    $SVN::_Core::SVN_CONFIG_OPTION_STORE_PASSWORDS,\n@@ -3073,7 +3069,7 @@ sub new {\n \t\t    1) == 0) {\n \t\t\t$Git::SVN::Prompt::_no_auth_cache = 1;\n \t\t}\n-\t}\n+\t} # no warnings 'once'\n \tmy $self = SVN::Ra->new(url => $url, auth => $baton,\n \t                      config => $config,\n \t\t\t      pool => SVN::Pool->new,\n-- \n1.5.3.2\n"},{"id":"55974","messageId":"20071016074318.GA32348@soma","threadId":"10287","inReplyTo":"20071015071912.GG984@void.codelabs.ru","subject":"Re: [PATCH] git-svn: use \"no warnings 'once'\" to disable false-positives","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2007-10-16T07:43:18Z","receivedAt":"2007-10-16T07:43:18Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Thanks, minor nit regarding fixed in the patch below.\n\n\t\"{ no warnings 'once';\"\n\non the same line as the \"{\"\n\nFrom: Eygene Ryabinkin <rea-git@codelabs.ru>\nDate: Mon, 15 Oct 2007 11:19:12 +0400\nSubject: [PATCH] git-svn: use \"no warnings 'once'\" to disable false-positives\n\nSome variables coming from the Subversion's Perl bindings are used\nin our code only once, so the interpreter warns us about it.  These\nwarnings are false-positives, because the variables themselves are\ninitialized in the binding's guts, that are made by SWIG.\n\nCredits to Sam Vilain for his note about \"no warnings 'once'\".\n\n[ew: minor formatting change]\n\nSigned-off-by: Eygene Ryabinkin <rea-git@codelabs.ru>\nAcked-by: Eric Wong <normalperson@yhbt.net>\n---\n git-svn.perl |   87 ++++++++++++++++++++++++++++-----------------------------\n 1 files changed, 43 insertions(+), 44 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 2c8a158..1130a09 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -2303,23 +2303,31 @@ sub ssl_server_trust {\n \tmy ($cred, $realm, $failures, $cert_info, $may_save, $pool) = @_;\n \t$may_save = undef if $_no_auth_cache;\n \tprint STDERR \"Error validating server certificate for '$realm':\\n\";\n-\tif ($failures & $SVN::Auth::SSL::UNKNOWNCA) {\n-\t\tprint STDERR \" - The certificate is not issued by a trusted \",\n-\t\t      \"authority. Use the\\n\",\n-\t              \"   fingerprint to validate the certificate manually!\\n\";\n-\t}\n-\tif ($failures & $SVN::Auth::SSL::CNMISMATCH) {\n-\t\tprint STDERR \" - The certificate hostname does not match.\\n\";\n-\t}\n-\tif ($failures & $SVN::Auth::SSL::NOTYETVALID) {\n-\t\tprint STDERR \" - The certificate is not yet valid.\\n\";\n-\t}\n-\tif ($failures & $SVN::Auth::SSL::EXPIRED) {\n-\t\tprint STDERR \" - The certificate has expired.\\n\";\n-\t}\n-\tif ($failures & $SVN::Auth::SSL::OTHER) {\n-\t\tprint STDERR \" - The certificate has an unknown error.\\n\";\n-\t}\n+\t{\n+\t\tno warnings 'once';\n+\t\t# All variables SVN::Auth::SSL::* are used only once,\n+\t\t# so we're shutting up Perl warnings about this.\n+\t\tif ($failures & $SVN::Auth::SSL::UNKNOWNCA) {\n+\t\t\tprint STDERR \" - The certificate is not issued \",\n+\t\t\t    \"by a trusted authority. Use the\\n\",\n+\t\t\t    \"   fingerprint to validate \",\n+\t\t\t    \"the certificate manually!\\n\";\n+\t\t}\n+\t\tif ($failures & $SVN::Auth::SSL::CNMISMATCH) {\n+\t\t\tprint STDERR \" - The certificate hostname \",\n+\t\t\t    \"does not match.\\n\";\n+\t\t}\n+\t\tif ($failures & $SVN::Auth::SSL::NOTYETVALID) {\n+\t\t\tprint STDERR \" - The certificate is not yet valid.\\n\";\n+\t\t}\n+\t\tif ($failures & $SVN::Auth::SSL::EXPIRED) {\n+\t\t\tprint STDERR \" - The certificate has expired.\\n\";\n+\t\t}\n+\t\tif ($failures & $SVN::Auth::SSL::OTHER) {\n+\t\t\tprint STDERR \" - The certificate has \",\n+\t\t\t    \"an unknown error.\\n\";\n+\t\t}\n+\t} # no warnings 'once'\n \tprintf STDERR\n \t        \"Certificate information:\\n\".\n \t        \" - Hostname: %s\\n\".\n@@ -2403,20 +2411,6 @@ sub _read_password {\n \t$password;\n }\n \n-package main;\n-\n-{\n-\tmy $kill_stupid_warnings = $SVN::Node::none.$SVN::Node::file.\n-\t\t\t\t$SVN::Node::dir.$SVN::Node::unknown.\n-\t\t\t\t$SVN::Node::none.$SVN::Node::file.\n-\t\t\t\t$SVN::Node::dir.$SVN::Node::unknown.\n-\t\t\t\t$SVN::Auth::SSL::CNMISMATCH.\n-\t\t\t\t$SVN::Auth::SSL::NOTYETVALID.\n-\t\t\t\t$SVN::Auth::SSL::EXPIRED.\n-\t\t\t\t$SVN::Auth::SSL::UNKNOWNCA.\n-\t\t\t\t$SVN::Auth::SSL::OTHER;\n-}\n-\n package SVN::Git::Fetcher;\n use vars qw/@ISA/;\n use strict;\n@@ -2833,16 +2827,21 @@ sub open_or_add_dir {\n \tif (!defined $t) {\n \t\tdie \"$full_path not known in r$self->{r} or we have a bug!\\n\";\n \t}\n-\tif ($t == $SVN::Node::none) {\n-\t\treturn $self->add_directory($full_path, $baton,\n-\t\t\t\t\t\tundef, -1, $self->{pool});\n-\t} elsif ($t == $SVN::Node::dir) {\n-\t\treturn $self->open_directory($full_path, $baton,\n-\t\t\t\t\t\t$self->{r}, $self->{pool});\n-\t}\n-\tprint STDERR \"$full_path already exists in repository at \",\n-\t\t\"r$self->{r} and it is not a directory (\",\n-\t\t($t == $SVN::Node::file ? 'file' : 'unknown'),\"/$t)\\n\";\n+\t{\n+\t\tno warnings 'once';\n+\t\t# SVN::Node::none and SVN::Node::file are used only once,\n+\t\t# so we're shutting up Perl's warnings about them.\n+\t\tif ($t == $SVN::Node::none) {\n+\t\t\treturn $self->add_directory($full_path, $baton,\n+\t\t\t    undef, -1, $self->{pool});\n+\t\t} elsif ($t == $SVN::Node::dir) {\n+\t\t\treturn $self->open_directory($full_path, $baton,\n+\t\t\t    $self->{r}, $self->{pool});\n+\t\t} # no warnings 'once'\n+\t\tprint STDERR \"$full_path already exists in repository at \",\n+\t\t    \"r$self->{r} and it is not a directory (\",\n+\t\t    ($t == $SVN::Node::file ? 'file' : 'unknown'),\"/$t)\\n\";\n+\t} # no warnings 'once'\n \texit 1;\n }\n \n@@ -3068,11 +3067,11 @@ sub new {\n \tmy $dont_store_passwords = 1;\n \tmy $conf_t = ${$config}{'config'};\n \t{\n+\t\tno warnings 'once';\n \t\t# The usage of $SVN::_Core::SVN_CONFIG_* variables\n \t\t# produces warnings that variables are used only once.\n \t\t# I had not found the better way to shut them up, so\n-\t\t# warnings are disabled in this block.\n-\t\tno warnings;\n+\t\t# the warnings of type 'once' are disabled in this block.\n \t\tif (SVN::_Core::svn_config_get_bool($conf_t,\n \t\t    $SVN::_Core::SVN_CONFIG_SECTION_AUTH,\n \t\t    $SVN::_Core::SVN_CONFIG_OPTION_STORE_PASSWORDS,\n@@ -3087,7 +3086,7 @@ sub new {\n \t\t    1) == 0) {\n \t\t\t$Git::SVN::Prompt::_no_auth_cache = 1;\n \t\t}\n-\t}\n+\t} # no warnings 'once'\n \tmy $self = SVN::Ra->new(url => $url, auth => $baton,\n \t                      config => $config,\n \t\t\t      pool => SVN::Pool->new,\n-- \n1.5.3.4.1173.gcfeee\n\n-- \nEric Wong\n"},{"id":"56077","messageId":"20071016165025.GT984@void.codelabs.ru","threadId":"10287","inReplyTo":"20071016074318.GA32348@soma","subject":"Re: [PATCH] git-svn: use \"no warnings 'once'\" to disable false-positives","fromName":"Eygene Ryabinkin","fromEmail":"rea-git@codelabs.ru","sentAt":"2007-10-16T16:50:25Z","receivedAt":"2007-10-16T16:50:25Z","isPatch":true,"sender":{"key":"rea-git@codelabs.ru","avatar":null},"body":"Eric, good day.\n\nTue, Oct 16, 2007 at 12:43:18AM -0700, Eric Wong wrote:\n> Thanks, minor nit regarding fixed in the patch below.\n> \n> \t\"{ no warnings 'once';\"\n> \n> on the same line as the \"{\"\n\nYes, I did this intentionally to signify that this block is used\njust for the pragma.  But I felt that it is against the style, so\nyou're right.\n\nThank you!\n-- \nEygene\n"}]}