diff-highlight: use flush() helper consistently

The current flush() helper only shows the queued diff but
does not clear the queue. This is conceptually a bug, but it
works because we only call it once at the end of the
program.

Let's teach it to clear the queue, which will let us use it
in more places (one for now, but more in future patches).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jeff King 2018-03-21 01:56:37 -04:00 committed by Junio C Hamano
parent fbcf99e4ac
commit 009a81ed97

View file

@ -46,10 +46,7 @@ sub handle_line {
push @added, $_;
}
else {
show_hunk(\@removed, \@added);
@removed = ();
@added = ();
flush();
$line_cb->($_);
$in_hunk = /^$GRAPH*$COLOR*[\@ ]/;
}
@ -71,6 +68,8 @@ sub flush {
# Flush any queued hunk (this can happen when there is no trailing
# context in the final diff of the input).
show_hunk(\@removed, \@added);
@removed = ();
@added = ();
}
sub highlight_stdin {