From 9dfa7ac3be181210dafd09ad68d10790a0810e18 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Mon, 27 Oct 2025 12:33:58 +0100 Subject: 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 Signed-off-by: Junio C Hamano --- cache-tree.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'cache-tree.c') diff --git a/cache-tree.c b/cache-tree.c index 2aba47060e..b67d0d703d 100644 --- a/cache-tree.c +++ b/cache-tree.c @@ -699,11 +699,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); @@ -723,7 +723,6 @@ struct tree* write_in_core_index_as_tree(struct repository *repo) { return lookup_tree(repo, &index_state->cache_tree->oid); } - int write_index_as_tree(struct object_id *oid, struct index_state *index_state, const char *index_path, int flags, const char *prefix) { int entries, was_valid; -- cgit v1.2.3