Re: [PATCH v4 8/9] add -p: fix counting when splitting and coalescing
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 1, 2018, 20:29 UTC
- Message-ID
- <xmqqsh9jfsjd.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <20180301105103.24268-9-phillip.wood@talktalk.net>
Phillip Wood <phillip.wood@talktalk.net> writes:
Show 11 quoted lines
> @@ -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.