From 9e5da3d055c558fc6492d3b996736ff7e8d115c3 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 17 Jan 2019 11:27:11 -0500 Subject: add: use separate ADD_CACHE_RENORMALIZE flag Commit 9472935d81 (add: introduce "--renormalize", 2017-11-16) taught git-add to pass HASH_RENORMALIZE to add_to_index(), which then passes the flag along to index_path(). However, the flags taken by add_to_index() and the ones taken by index_path() are distinct namespaces. We cannot take HASH_* flags in add_to_index(), because they overlap with the ADD_CACHE_* flags we already take (in this case, HASH_RENORMALIZE conflicts with ADD_CACHE_IGNORE_ERRORS). We can solve this by adding a new ADD_CACHE_RENORMALIZE flag, and using it to set HASH_RENORMALIZE within add_to_index(). In order to make it clear that these two flags come from distinct sets, let's also change the name "newflags" in the function to "hash_flags". Reported-by: Dmitriy Smirnov Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- read-cache.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'read-cache.c') diff --git a/read-cache.c b/read-cache.c index 8f644f68b4..ce679c1799 100644 --- a/read-cache.c +++ b/read-cache.c @@ -694,10 +694,10 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st, int intent_only = flags & ADD_CACHE_INTENT; int add_option = (ADD_CACHE_OK_TO_ADD|ADD_CACHE_OK_TO_REPLACE| (intent_only ? ADD_CACHE_NEW_ONLY : 0)); - int newflags = HASH_WRITE_OBJECT; + int hash_flags = HASH_WRITE_OBJECT; - if (flags & HASH_RENORMALIZE) - newflags |= HASH_RENORMALIZE; + if (flags & ADD_CACHE_RENORMALIZE) + hash_flags |= HASH_RENORMALIZE; if (!S_ISREG(st_mode) && !S_ISLNK(st_mode) && !S_ISDIR(st_mode)) return error("%s: can only add regular files, symbolic links or git-directories", path); @@ -753,7 +753,7 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st, } } if (!intent_only) { - if (index_path(&ce->oid, path, st, newflags)) { + if (index_path(&ce->oid, path, st, hash_flags)) { discard_cache_entry(ce); return error("unable to index file %s", path); } -- cgit v1.3