From: Junio C Hamano Date: Thu, 26 Jul 2018 19:36:29 GMT Subject: Re: [PATCH v5 1/4] add -p: select individual hunk lines Message-ID: In-Reply-To: <20180726155854.20832-2-phillip.wood@talktalk.net> Phillip Wood writes: > +sub label_hunk_lines { > + my $hunk = shift; > + my $text = $hunk->{TEXT}; > + my (@line_flags, @lines); > + my ($block, $label, $last_mode) = (0, 0, ''); > + for my $line (1..$#{$text}) { $text is a ref to an array so @$text is the whole thing, $#{$text} is the index of the last item in that array, and $text->[0] is the first element of that array. This for loop runs with $line == 1 thru $line == $#{$text}, so we are somehow excluding the very first element? > + $line_flags[$line] = 0; > + my $mode = substr($text->[$line], 0, 1); > + if ($mode eq '\\') { > + $line_flags[$line - 1] |= NO_NEWLINE; > + } > + if ($mode eq '-' or $mode eq '+') { > + $lines[++$label] = $line; > + } > + } > + if ($label > 1) {