cache-tree: allow writing in-memory index as tree

The function `write_in_core_index_as_tree()` takes a repository and
writes its index into a tree object. What this function cannot do though
is to take an _arbitrary_ in-memory index.

Introduce a new `struct index_state` parameter so that the caller can
pass a different index than the one belonging to the repository. This
will be used in a subsequent commit.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt
2026-03-02 13:13:10 +01:00
committed by Junio C Hamano
parent 48f6d92328
commit a021e4f92c
3 changed files with 6 additions and 4 deletions

View File

@@ -723,11 +723,11 @@ static int write_index_as_tree_internal(struct object_id *oid,
return 0;
}
struct tree* write_in_core_index_as_tree(struct repository *repo) {
struct tree *write_in_core_index_as_tree(struct repository *repo,
struct index_state *index_state) {
struct object_id o;
int was_valid, ret;
struct index_state *index_state = repo->index;
was_valid = index_state->cache_tree &&
cache_tree_fully_valid(index_state->cache_tree);