Re: [PATCH v5 1/4] add -p: select individual hunk lines

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Phillip Wood <phillip.wood@xxxxxxxxxxxx> writes:

> On 26/07/18 20:36, Junio C Hamano wrote:
>> Phillip Wood <phillip.wood@xxxxxxxxxxxx> 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?
>
> Yes that's right, $text->[0] contains the hunk header

OK, thanks.

>
>>> +		$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) {



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux