Re: [PATCH 1/2] read-cache: do not trust a size change when conversion is active
Junio C Hamano <gitster@pobox.com> writes:
> That's overly verbose.
> ... Why do we need to add a new function that compares converted
> data?
We don't. The fix is only this:
--- a/read-cache.c
+++ b/read-cache.c
@@ -9,6 +9,7 @@
#include "git-compat-util.h"
#include "config.h"
+#include "convert.h"
#include "date.h"
@@ -480,7 +481,8 @@ int ie_modified(struct index_state *istate,
- (S_ISGITLINK(ce->ce_mode) || ce->ce_stat_data.sd_size != 0))
+ (S_ISGITLINK(ce->ce_mode) || ce->ce_stat_data.sd_size != 0) &&
+ !(S_ISREG(st->st_mode) && would_convert_to_git(istate, ce->name)))
return changed;
The existing index_fd() path then does the comparison, as it does when
only the mtime changed. I have built and tested the fix by itself on
top of 6de20f6: the new t0020 tests pass with it and fail without it.
The rest is an optimization that skips converting and hashing when the
length already rules out a match. I added it, and patch 2, expecting
cost to be the objection. It belongs in a separate patch.
Without it, status on 200 modified 1 MB files under "* text=auto"
takes 507ms instead of 3ms, and on 10000 modified 2.6 KB files 129ms
instead of 20ms -- the same work the mtime branch already does.
After the first run, status on 10000 CRLF-rewritten 2.6 KB files
drops from 21ms to 5ms, because the index records their new sizes.
Shall I send v2 as only the fix, with a short log message, and offer
the rest separately if wanted?