Re: [PATCH 01/24] dir.c: optionally compute sha-1 of a .gitignore file
From: Junio C Hamano <hidden>
Date: 2016-06-15 23:03:50
Duy Nguyen [off-list ref] writes:
On Thu, Feb 12, 2015 at 4:23 AM, Junio C Hamano [off-list ref] wrote: ...quoted
If you want to detect the content changes across working tree, index and the tree objects by reusing hash_sha1_file(), however, you must not feed the checked out (aka "smudged") representation to it. You'd need to turn it into "cleaned" representation by doing the equivalent of calling index_path(). Some helpers in the callchain that originates from index_path() might directly be reusable for your purpose.Urgh.. you're right this test would fail when some filters are involved. I'm not sure if we want to check the cleaned version though. What matters to exclude machinery is the checkout version.
Oh, I wouldn't suggest getting lines from the cleaned version. It is just that you must hash the cleaned version if you want to decide "Ah, the content is different from what the internal cache is based on, so I need to invalidate my cache" and "Because the version I have on the filesystem matches what is in the index, which is what my cache is based on, I would use my cached version". The latter would break (i.e. the signature would not match when it should) and you end up invalidating the cache when you do not have to.