Re: [PATCH 4/4] diffcore-delta.c: Ignore CR in CRLF for text files
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:43:18
しらいしななこ [off-list ref] writes:
Quoting Junio C Hamano [off-list ref]:quoted
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.