Re: [PATCH 4/4] diffcore-delta.c: Ignore CR in CRLF for text files

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

 



しらいしななこ  <nanako3@xxxxxxxxxxxxxx> writes:

> Quoting Junio C Hamano <gitster@xxxxxxxxx>:
>
>> This ignores CR byte in CRLF sequence in text file when
>> computing similarity of two blobs.
>> ...
>> +test_expect_success 'diff -M' '
>> +
>> +	git diff-tree -M -r --name-status HEAD^ HEAD |
>> +	sed -e "s/R[0-9]*/RNUM/" >actual &&
>> +	echo "RNUM	sample	elpmas" >expect &&
>> +	diff -u expect actual
>> +
>> +'
>
> I tried this test but it does not give R100.  The new file is unchanged except for
> LF -> CRLF.  Could you explain why?

Heh, I hate when people nitpick me ;-)

The similarity code counts "bytes copied from the source
material to the destination" and "bytes added to the source to
create the destination".

Rename detection uses only the former value.  The amount of data
copied from the source is divided by the larger of the size of
source or destination.

In the case of our test script, the source material is about 560
bytes, while the destination material is about 590 bytes, after 
adding CR to the end of every line.  We find that 560 bytes have
been copied from the source material, and floor(560 * 100 / 590)
is 94%, which is what you would see as the result.

We could adjust max_size variable inside diffcore_count_changes,
but I am not sure if it is worth the trouble.




-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[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