From: Junio C Hamano Date: Thu, 01 Mar 2018 20:29:58 GMT Subject: Re: [PATCH v4 8/9] add -p: fix counting when splitting and coalescing Message-ID: In-Reply-To: <20180301105103.24268-9-phillip.wood@talktalk.net> Phillip Wood writes: > @@ -887,8 +892,8 @@ sub merge_hunk { > $o_cnt = $n_cnt = 0; > for ($i = 1; $i < @{$prev->{TEXT}}; $i++) { > my $line = $prev->{TEXT}[$i]; > - if ($line =~ /^\+/) { > - $n_cnt++; > + if ($line =~ /^[+\\]/) { > + $n_cnt++ if ($line =~ /^\+/); > push @line, $line; > next; > } Hmmmm, the logic may be correct, but this looks like a result of attempting to minimize the number of changed lines and ending up with a less-than-readble code. "If the line begins with a plus or backslash, do these things, the first of which is done only when the line begins with a plus." The same comment for the other hunk that counts the $this side.