summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cache-tree.c4
-rwxr-xr-xt/t2203-add-intent.sh17
2 files changed, 19 insertions, 2 deletions
diff --git a/cache-tree.c b/cache-tree.c
index ddf0cc9f9a..c2676e8a31 100644
--- a/cache-tree.c
+++ b/cache-tree.c
@@ -319,7 +319,7 @@ static int update_one(struct cache_tree *it,
i = 0;
while (i < entries) {
const struct cache_entry *ce = cache[i];
- struct cache_tree_sub *sub;
+ struct cache_tree_sub *sub = NULL;
const char *path, *slash;
int pathlen, entlen;
const unsigned char *sha1;
@@ -375,7 +375,7 @@ static int update_one(struct cache_tree *it,
* they are not part of generated trees. Invalidate up
* to root to force cache-tree users to read elsewhere.
*/
- if (ce_intent_to_add(ce)) {
+ if (!sub && ce_intent_to_add(ce)) {
to_invalidate = 1;
continue;
}
diff --git a/t/t2203-add-intent.sh b/t/t2203-add-intent.sh
index 2a4a749b4f..24aed2e541 100755
--- a/t/t2203-add-intent.sh
+++ b/t/t2203-add-intent.sh
@@ -82,5 +82,22 @@ test_expect_success 'cache-tree invalidates i-t-a paths' '
test_cmp expect actual
'
+test_expect_success 'cache-tree does not ignore dir that has i-t-a entries' '
+ git init ita-in-dir &&
+ (
+ cd ita-in-dir &&
+ mkdir 2 &&
+ for f in 1 2/1 2/2 3
+ do
+ echo "$f" >"$f"
+ done &&
+ git add 1 2/2 3 &&
+ git add -N 2/1 &&
+ git commit -m committed &&
+ git ls-tree -r HEAD >actual &&
+ grep 2/2 actual
+ )
+'
+
test_done