summaryrefslogtreecommitdiff
path: root/read-cache.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2019-01-17 16:27:11 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-01-17 21:40:21 (GMT)
commit9e5da3d055c558fc6492d3b996736ff7e8d115c3 (patch)
tree926b700c6e2b8af1d0a206be0c5e27e88b2f739c /read-cache.c
parent98cdfbb84ad2ed6a2eb43dafa357a70a4b0a0fad (diff)
downloadgit-9e5da3d055c558fc6492d3b996736ff7e8d115c3.zip
git-9e5da3d055c558fc6492d3b996736ff7e8d115c3.tar.gz
git-9e5da3d055c558fc6492d3b996736ff7e8d115c3.tar.bz2
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 <dmitriy.smirnov@jetbrains.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.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/read-cache.c b/read-cache.c
index 8f644f6..ce679c1 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);
}