@@ -86,42 +86,52 @@ if (!$has_stdin) {
86
86
} else {
87
87
die (" Missing input on STDIN\n " );
88
88
}
89
- } else {
90
- # Check to see if were using default settings
91
- check_first_run();
92
-
93
- my @lines ;
94
- local $DiffHighlight::line_cb = sub {
95
- push (@lines ,@_ );
96
-
97
- my $last_line = $lines [-1];
98
-
99
- # Buffer X lines before we try and output anything
100
- # Also make sure we're sending enough data to d-s-f to do it's magic.
101
- # Certain things require a look-ahead line or two to function so
102
- # we make sure we don't break on those sections prematurely
103
- if (@lines > 24 && ($last_line !~ / ^${ansi_color_regex} (---|index|old mode|similarity index|rename (from|to))/ )) {
104
- do_dsf_stuff(\@lines );
105
- @lines = ();
106
- }
107
- };
89
+ }
108
90
109
- my $line_count = 0;
110
- while (my $line = <STDIN >) {
111
- # If the very first line of the diff doesn't start with ANSI color we're assuming
112
- # it's a raw patch file, and we have to color the added/removed lines ourself
113
- if (!$color_forced && $line_count == 0 && starts_with_ansi($line )) {
114
- $manually_color_lines = 1;
115
- }
91
+ # ################################################################################
92
+ # ################################################################################
93
+
94
+ # Check to see if were using default settings
95
+ check_first_run();
116
96
117
- my $ok = DiffHighlight::handle_line($line );
118
- $line_count ++;
97
+ # The logic here is that we run all the lines through DiffHighlight first. This
98
+ # highlights all the intra-word changes. Then we take those lines and send them
99
+ # to do_dsf_stuff() to convert the diff to human readable d-s-f output and add
100
+ # appropriate fanciness
101
+
102
+ my @lines ;
103
+ local $DiffHighlight::line_cb = sub {
104
+ push (@lines ,@_ );
105
+
106
+ my $last_line = $lines [-1];
107
+
108
+ # Buffer X lines before we try and output anything
109
+ # Also make sure we're sending enough data to d-s-f to do it's magic.
110
+ # Certain things require a look-ahead line or two to function so
111
+ # we make sure we don't break on those sections prematurely
112
+ if (@lines > 24 && ($last_line !~ / ^${ansi_color_regex} (---|index|old mode|similarity index|rename (from|to))/ )) {
113
+ do_dsf_stuff(\@lines );
114
+ @lines = ();
115
+ }
116
+ };
117
+
118
+ my $line_count = 0;
119
+ while (my $line = <STDIN >) {
120
+ # If the very first line of the diff doesn't start with ANSI color we're assuming
121
+ # it's a raw patch file, and we have to color the added/removed lines ourself
122
+ if (!$color_forced && $line_count == 0 && starts_with_ansi($line )) {
123
+ $manually_color_lines = 1;
119
124
}
120
125
121
- DiffHighlight::flush( );
122
- do_dsf_stuff(\ @lines ) ;
126
+ my $ok = DiffHighlight::handle_line( $line );
127
+ $line_count ++ ;
123
128
}
124
129
130
+ # If we're mid hunk above process anything still pending
131
+ DiffHighlight::flush();
132
+ do_dsf_stuff(\@lines );
133
+
134
+ # ################################################################################
125
135
# ################################################################################
126
136
127
137
sub do_dsf_stuff {
0 commit comments