Commit ef4f1434 authored by Rohan McGovern's avatar Rohan McGovern Committed by Oswald Buddenhagen
Browse files

sanitize-commit: combine $ln and $lineno variables


Use a single variable for the current line number of the commit message
and of the current file, in preparation for new checks which use this information.

Note that $lineno always counts from 1. Previously, $ln counted from 0 while
$lineno counted from 1.

Change-Id: I3a87d29df1378e304a27a7672630f0319dc863a2
Reviewed-by: default avatarSergio Ahumada <sergio.ahumada@digia.com>
Reviewed-by: default avatarOswald Buddenhagen <oswald.buddenhagen@digia.com>
parent 71131585
No related merge requests found
Showing with 6 additions and 5 deletions
......@@ -88,7 +88,7 @@ sub complain()
}
}
my $ln = 0;
my $lineno = 0;
my $iswip = defined($cfg{wip});
my $revok = defined($cfg{revby});
my $badlog = defined($cfg{log});
......@@ -108,7 +108,8 @@ while (<MSG>) {
}
next
}
if ($ln == 0) {
$lineno++;
if ($lineno == 1) {
$summary = $_;
$revert1 = 1 if (/^Revert ".*"$/);
if (!$iswip && $parents < 2 && /\bWIP\b|\*{3}|^(?:squash|fixup)! |^(.)\1*$/i) {
......@@ -126,7 +127,7 @@ while (<MSG>) {
} elsif (!/^[-\w]+:|^$/) {
$nonrevert = 1;
}
if ($ln == 1) {
if ($lineno == 2) {
if (!$badlog && $_ ne "") {
&complain("2nd line of log message is not empty", "log");
}
......@@ -137,7 +138,6 @@ while (<MSG>) {
}
}
}
$ln++;
}
close MSG;
printerr;
......@@ -159,7 +159,6 @@ my @deli = ();
my $nonws;
my $ws;
my $mixws_check = 0;
my $lineno = 0;
my @ws_files = ();
my %ws_lines = (); # hash of lists
my $braces = 0;
......@@ -168,6 +167,8 @@ my $close_key = qr/\s*#\s*endif|.*}/;
my $kill_all_ws = qr/\s+((?:\"(?:\\.|[^\"])*\"|\S)+)/; # Collapse all whitespace not inside strings.
my $kill_nl_ws = qr/((?:\"(?:\\.|[^\"])*\"|\S)+)\s+/; # Collapse all non-leading whitespace not inside strings.
$lineno = 0;
sub flushChunk()
{
my $loc_nonws = 0;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment