nodist: Fix git_untabify --narrow.

This commit is contained in:
Wilson Snyder 2019-05-16 21:32:50 -04:00
parent 01725f662f
commit 8d6bea8975

View File

@ -87,27 +87,30 @@ sub find_edits {
my $hunk = $editlines->{$lineno}{hunk}; my $hunk = $editlines->{$lineno}{hunk};
$hunk_lastlines{$hunk} ||= $lineno if $editlines->{$lineno}{user_edit}; $hunk_lastlines{$hunk} ||= $lineno if $editlines->{$lineno}{user_edit};
} }
# Expand to include }'s that finish basic block
foreach my $hunk (keys %hunk_lastlines) { if ($Opt_Widen) {
while (my $lineno = $hunk_lastlines{$hunk}) { # Expand to include }'s that finish basic block
++$lineno; foreach my $hunk (keys %hunk_lastlines) {
if (($editlines->{$lineno}{line} || "") while (my $lineno = $hunk_lastlines{$hunk}) {
=~ /^[+ ]\s+}[ \t};]*$/) { ++$lineno;
$hunk_lastlines{$hunk} = $lineno; if (($editlines->{$lineno}{line} || "")
} else { =~ /^[+ ]\s+}[ \t};]*$/) {
last; $hunk_lastlines{$hunk} = $lineno;
} else {
last;
}
} }
} }
} # Expand to always untabify at least 3 lines (so that future diff will
# Expand to always untabify at least 3 lines (so that future diff will # have non-tabs within a edit hunk distance
# have non-tabs within a edit hunk distance foreach my $hunk (keys %hunk_firstlines) {
foreach my $hunk (keys %hunk_firstlines) { if ($hunk_firstlines{$hunk} == $hunk_lastlines{$hunk}) {
if ($hunk_firstlines{$hunk} == $hunk_lastlines{$hunk}) { --$hunk_firstlines{$hunk};
--$hunk_firstlines{$hunk}; ++$hunk_lastlines{$hunk};
++$hunk_lastlines{$hunk}; }
} elsif ($hunk_firstlines{$hunk}+1 == $hunk_lastlines{$hunk}) {
elsif ($hunk_firstlines{$hunk}+1 == $hunk_lastlines{$hunk}) { ++$hunk_lastlines{$hunk};
++$hunk_lastlines{$hunk}; }
} }
} }