diff mbox series

[v3,08/26] commit: ensure full index

Message ID 1a3b51fd3c4bdfc50fa390d04c49b49acc47b90a.1618261698.git.gitgitgadget@gmail.com (mailing list archive)
State Accepted
Commit cb8388df5b3252802a0149ca558f99307e42074c
Headers show
Series Sparse Index: API protections | expand

Commit Message

Derrick Stolee April 12, 2021, 9:07 p.m. UTC
From: Derrick Stolee <dstolee@microsoft.com>

These two loops iterate over all cache entries, so ensure that a sparse
index is expanded to a full index before we do so.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
---
 builtin/commit.c | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/builtin/commit.c b/builtin/commit.c
index 739110c5a7f6..cf0c36d1dcb2 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -251,6 +251,8 @@  static int list_paths(struct string_list *list, const char *with_tree,
 		free(max_prefix);
 	}
 
+	/* TODO: audit for interaction with sparse-index. */
+	ensure_full_index(&the_index);
 	for (i = 0; i < active_nr; i++) {
 		const struct cache_entry *ce = active_cache[i];
 		struct string_list_item *item;
@@ -931,6 +933,8 @@  static int prepare_to_commit(const char *index_file, const char *prefix,
 		if (get_oid(parent, &oid)) {
 			int i, ita_nr = 0;
 
+			/* TODO: audit for interaction with sparse-index. */
+			ensure_full_index(&the_index);
 			for (i = 0; i < active_nr; i++)
 				if (ce_intent_to_add(active_cache[i]))
 					ita_nr++;