Re: [PATCH v4 0/4] cache-tree building fix in the presence of ita entries
From: Junio C Hamano <hidden>
Date: 2016-07-18 20:48:54
Nguyễn Thái Ngọc Duy [off-list ref] writes:
quoted hunk
v4 removes the leading underscore from _EMPTY_BLOB and _EMPTY_TREE and updates 4/4 slightly like this.diff --git a/cache-tree.c b/cache-tree.c index 2d50640..f28b1f4 100644 --- a/cache-tree.c +++ b/cache-tree.c@@ -325,6 +325,7 @@ static int update_one(struct cache_tree *it, const unsigned char *sha1; unsigned mode; int expected_missing = 0; + int contains_ita = 0; path = ce->name; pathlen = ce_namelen(ce);@@ -341,7 +342,8 @@ static int update_one(struct cache_tree *it, i += sub->count; sha1 = sub->cache_tree->sha1; mode = S_IFDIR; - if (sub->cache_tree->entry_count < 0) { + contains_ita = sub->cache_tree->entry_count < 0; + if (contains_ita) { to_invalidate = 1; expected_missing = 1; }@@ -381,10 +383,9 @@ static int update_one(struct cache_tree *it, } /* - * "sub" can be an empty tree if subentries are i-t-a. + * "sub" can be an empty tree if all subentries are i-t-a. */ - if (sub && sub->cache_tree->entry_count < 0 && - !hashcmp(sha1, EMPTY_TREE_SHA1_BIN)) + if (contains_ita && !hashcmp(sha1, EMPTY_TREE_SHA1_BIN)) continue; strbuf_grow(&buffer, entlen + 100);
This makes quite a lot of sense; even though I do not think it would change the behaviour within the context of current code, it definitely is easier to understand and prevents future mistakes. Will queue. Thanks.