summaryrefslogtreecommitdiff
path: root/cache.h
diff options
context:
space:
mode:
authorVictoria Dye <vdye@github.com>2021-11-29 15:52:41 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-11-29 20:51:26 (GMT)
commit20ec2d034cda1afef15a4dcc6e275d7a69413510 (patch)
tree1461ef3b8acc4895f8e31ded1d9674c8fb0a7318 /cache.h
parentc01b1cbd473c05e29fe0c1a31b8f6539e82c4559 (diff)
downloadgit-20ec2d034cda1afef15a4dcc6e275d7a69413510.zip
git-20ec2d034cda1afef15a4dcc6e275d7a69413510.tar.gz
git-20ec2d034cda1afef15a4dcc6e275d7a69413510.tar.bz2
reset: make sparse-aware (except --mixed)
Remove `ensure_full_index` guard on `prime_cache_tree` and update `prime_cache_tree_rec` to correctly reconstruct sparse directory entries in the cache tree. While processing a tree's entries, `prime_cache_tree_rec` must determine whether a directory entry is sparse or not by searching for it in the index (*without* expanding the index). If a matching sparse directory index entry is found, no subtrees are added to the cache tree entry and the entry count is set to 1 (representing the sparse directory itself). Otherwise, the tree is assumed to not be sparse and its subtrees are recursively added to the cache tree. Helped-by: Elijah Newren <newren@gmail.com> Signed-off-by: Victoria Dye <vdye@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'cache.h')
-rw-r--r--cache.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/cache.h b/cache.h
index 3e5658c..5212ea2 100644
--- a/cache.h
+++ b/cache.h
@@ -817,6 +817,16 @@ struct cache_entry *index_file_exists(struct index_state *istate, const char *na
int index_name_pos(struct index_state *, const char *name, int namelen);
/*
+ * Determines whether an entry with the given name exists within the
+ * given index. The return value is 1 if an exact match is found, otherwise
+ * it is 0. Note that, unlike index_name_pos, this function does not expand
+ * the index if it is sparse. If an item exists within the full index but it
+ * is contained within a sparse directory (and not in the sparse index), 0 is
+ * returned.
+ */
+int index_entry_exists(struct index_state *, const char *name, int namelen);
+
+/*
* Some functions return the negative complement of an insert position when a
* precise match was not found but a position was found where the entry would
* need to be inserted. This helper protects that logic from any integer