Skip to content

Commit 009a81e

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fbcf99e commit 009a81e

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

contrib/diff-highlight/DiffHighlight.pm

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,7 @@ sub handle_line {
4646
push @added, $_;
4747
}
4848
else {
49-
show_hunk(\@removed, \@added);
50-
@removed = ();
51-
@added = ();
52-
49+
flush();
5350
$line_cb->($_);
5451
$in_hunk = /^$GRAPH*$COLOR*[\@ ]/;
5552
}
@@ -71,6 +68,8 @@ sub flush {
7168
# Flush any queued hunk (this can happen when there is no trailing
7269
# context in the final diff of the input).
7370
show_hunk(\@removed, \@added);
71+
@removed = ();
72+
@added = ();
7473
}
7574

7675
sub highlight_stdin {

0 commit comments

Comments
 (0)