merge-ort: pass repository to write_tree()
In order to get rid of a usage of the_repository, we need to know the value of opt->repo; pass it along to write_tree(). Once we have the repository, though, we no longer need to pass opt->repo->hash_algo->rawsz, we can have write_tree() look up that value itself. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Elijah Newren committed
Feb 21, 2026 at 23:59 UTC
4f8108b5ff8937720844cec95d2c5b6b22cec03b
1 file changed
+8
-8
merge-ort.c
+8
-8
@@ -3822,15 +3822,16 @@ static int tree_entry_order(const void *a_, const void *b_)
3822
b->string, strlen(b->string), bmi->result.mode);
3823
}
3824
3825
-static int write_tree(struct object_id *result_oid,
3825
+static int write_tree(struct repository *repo,
3826
+ struct object_id *result_oid,
3827
struct string_list *versions,
3827
- unsigned int offset,
3828
- size_t hash_size)
3828
+ unsigned int offset)
3829
{
3830
size_t maxlen = 0, extra;
3831
unsigned int nr;
3832
struct strbuf buf = STRBUF_INIT;
3833
int i, ret = 0;
3834
+ size_t hash_size = repo->hash_algo->rawsz;
3835
3836
assert(offset <= versions->nr);
3837
nr = versions->nr - offset;
@@ -3856,7 +3857,7 @@ static int write_tree(struct object_id *result_oid,
3857
}
3858
3859
/* Write this object file out, and record in result_oid */
3859
- if (odb_write_object(the_repository->objects, buf.buf,
3860
+ if (odb_write_object(repo->objects, buf.buf,
3861
buf.len, OBJ_TREE, result_oid))
3862
ret = -1;
3863
strbuf_release(&buf);
@@ -4026,8 +4027,8 @@ static int write_completed_directory(struct merge_options *opt,
4027
dir_info->is_null = 0;
4028
dir_info->result.mode = S_IFDIR;
4029
if (record_tree &&
4029
- write_tree(&dir_info->result.oid, &info->versions, offset,
4030
- opt->repo->hash_algo->rawsz) < 0)
4030
+ write_tree(opt->repo, &dir_info->result.oid, &info->versions,
4031
+ offset) < 0)
4032
ret = -1;
4033
}
4034
@@ -4573,8 +4574,7 @@ static int process_entries(struct merge_options *opt,
4574
BUG("dir_metadata accounting completely off; shouldn't happen");
4575
}
4576
if (record_tree &&
4576
- write_tree(result_oid, &dir_metadata.versions, 0,
4577
- opt->repo->hash_algo->rawsz) < 0)
4577
+ write_tree(opt->repo, result_oid, &dir_metadata.versions, 0) < 0)
4578
ret = -1;
4579
cleanup:
4580
string_list_clear(&plist, 0);