Skip to content

Commit 46082c3

Browse files
author
Edward Thomson
committed
index_read_index: invalidate new paths in tree cache
When adding a new entry to an existing index via `git_index_read_index`, be sure to remove the tree cache entry for that new path. This will mark all parent trees as dirty.
1 parent 5acf18a commit 46082c3

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/index.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3004,6 +3004,12 @@ int git_index_read_index(
30043004
((struct entry_internal *)add_entry)->pathlen);
30053005
}
30063006

3007+
/* invalidate this path in the tree cache if this is new (to
3008+
* invalidate the parent trees)
3009+
*/
3010+
if (dup_entry && !remove_entry && index->tree)
3011+
git_tree_cache_invalidate_path(index->tree, dup_entry->path);
3012+
30073013
if (add_entry) {
30083014
if ((error = git_vector_insert(&new_entries, add_entry)) == 0)
30093015
INSERT_IN_MAP_EX(index, new_entries_map, add_entry, error);

0 commit comments

Comments
 (0)