summaryrefslogtreecommitdiff
path: root/read-cache.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2019-02-07 02:00:22 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-02-07 02:56:45 (GMT)
commite2c2a37545f604988424100ed6b1732eb5f36b55 (patch)
tree0fdf6475b5953ad7a64bf266dc669b678a5f8928 /read-cache.c
parent9e5da3d055c558fc6492d3b996736ff7e8d115c3 (diff)
downloadgit-e2c2a37545f604988424100ed6b1732eb5f36b55.zip
git-e2c2a37545f604988424100ed6b1732eb5f36b55.tar.gz
git-e2c2a37545f604988424100ed6b1732eb5f36b55.tar.bz2
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 <szeder.dev@gmail.com> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'read-cache.c')
-rw-r--r--read-cache.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/read-cache.c b/read-cache.c
index ce679c1..03ea8fb 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 &&