Inter-revision diff: patch 25

Comparing v2 (message) to v1 (message)

--- v2
+++ v1
@@ -1,64 +1,28 @@
 From: Derrick Stolee <dstolee@microsoft.com>
 
-A sparse-index loads the name-hash data for its entries, including the
-sparse-directory entries. If a caller asks for a path that is contained
-within a sparse-directory entry, we need to expand to a full index and
-recalculate the name hash table before returning the result. Insert
-calls to expand_to_path() to protect against this case.
+Before iterating over all index entries, ensure that a sparse index is
+expanded to a full index to avoid unexpected behavior. This case could
+be integrated later by ensuring that we walk the tree in the
+sparse-directory entry, but the current behavior is only expecting
+blobs. Save this integration for later when it can be properly tested.
 
 Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
 ---
- name-hash.c | 10 ++++++++++
- 1 file changed, 10 insertions(+)
+ revision.c | 1 +
+ 1 file changed, 1 insertion(+)
 
-diff --git a/name-hash.c b/name-hash.c
-index 4e03fac9bb12..75c159e06eeb 100644
---- a/name-hash.c
-+++ b/name-hash.c
-@@ -8,6 +8,7 @@
- #include "cache.h"
- #include "thread-utils.h"
- #include "trace2.h"
-+#include "sparse-index.h"
+diff --git a/revision.c b/revision.c
+index b78733f5089b..1eee55934c08 100644
+--- a/revision.c
++++ b/revision.c
+@@ -1680,6 +1680,7 @@ static void do_add_index_objects_to_pending(struct rev_info *revs,
+ {
+ 	int i;
  
- struct dir_entry {
- 	struct hashmap_entry ent;
-@@ -109,6 +110,12 @@ static void hash_index_entry(struct index_state *istate, struct cache_entry *ce)
- 	if (ce->ce_flags & CE_HASHED)
- 		return;
- 	ce->ce_flags |= CE_HASHED;
-+
-+	if (S_ISSPARSEDIR(ce->ce_mode)) {
-+		add_dir_entry(istate, ce);
-+		return;
-+	}
-+
- 	hashmap_entry_init(&ce->ent, memihash(ce->name, ce_namelen(ce)));
- 	hashmap_add(&istate->name_hash, &ce->ent);
- 
-@@ -680,6 +687,7 @@ int index_dir_exists(struct index_state *istate, const char *name, int namelen)
- 	struct dir_entry *dir;
- 
- 	lazy_init_name_hash(istate);
-+	expand_to_path(istate, name, namelen, 0);
- 	dir = find_dir_entry(istate, name, namelen);
- 	return dir && dir->nr;
- }
-@@ -690,6 +698,7 @@ void adjust_dirname_case(struct index_state *istate, char *name)
- 	const char *ptr = startPtr;
- 
- 	lazy_init_name_hash(istate);
-+	expand_to_path(istate, name, strlen(name), 0);
- 	while (*ptr) {
- 		while (*ptr && *ptr != '/')
- 			ptr++;
-@@ -713,6 +722,7 @@ struct cache_entry *index_file_exists(struct index_state *istate, const char *na
- 	unsigned int hash = memihash(name, namelen);
- 
- 	lazy_init_name_hash(istate);
-+	expand_to_path(istate, name, namelen, icase);
- 
- 	ce = hashmap_get_entry_from_hash(&istate->name_hash, hash, NULL,
- 					 struct cache_entry, ent);
++	ensure_full_index(istate);
+ 	for (i = 0; i < istate->cache_nr; i++) {
+ 		struct cache_entry *ce = istate->cache[i];
+ 		struct blob *blob;
 -- 
 gitgitgadget
+
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help