From: Jeff King Date: Thu, 7 Feb 2019 02:00:22 +0000 (-0500) Subject: add_to_index(): convert forgotten HASH_RENORMALIZE check X-Git-Tag: v2.21.0-rc0~1^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e2c2a37545f604988424100ed6b1732eb5f36b55;p=thirdparty%2Fgit.git add_to_index(): convert forgotten HASH_RENORMALIZE check Commit 9e5da3d055 (add: use separate ADD_CACHE_RENORMALIZE flag, 2019-01-17) switched out using HASH_RENORMALIZE in our flags field for a new ADD_CACHE_RENORMALIZE flag. However, it forgot to convert one of the checks for HASH_RENORMALIZE into the new flag, which totally broke "git add --renormalize". To make matters even more confusing, the resulting code would racily pass the tests! The forgotten check was responsible for defeating the up-to-date check of the index entry. That meant that "git add --renormalize" would refuse to renormalize things that appeared stat-clean. But most of the time the test commands run fast enough that the file mtime is the same as the index mtime. And thus we err on the conservative side and re-hash the file, which is what "--renormalize" would have wanted. But if you're unlucky and cross that one-second boundary between writing the file and writing the index (which is more likely to happen on a slow or heavily-loaded system), then the file appears stat-clean. And "--renormalize" would effectively do nothing. The fix is straightforward: convert this check to use the right flag. Noticed-by: SZEDER Gábor Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- diff --git a/read-cache.c b/read-cache.c index ce679c1799..03ea8fbd03 100644 --- a/read-cache.c +++ b/read-cache.c @@ -737,7 +737,7 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st, if (ignore_case) { adjust_dirname_case(istate, ce->name); } - if (!(flags & HASH_RENORMALIZE)) { + if (!(flags & ADD_CACHE_RENORMALIZE)) { alias = index_file_exists(istate, ce->name, ce_namelen(ce), ignore_case); if (alias &&