]> git.ipfire.org Git - thirdparty/git.git/commitdiff
merge-ort: pass repository to write_tree()
authorElijah Newren <newren@gmail.com>
Sat, 21 Feb 2026 23:59:49 +0000 (23:59 +0000)
committerJunio C Hamano <gitster@pobox.com>
Sun, 22 Feb 2026 02:34:06 +0000 (18:34 -0800)
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>
merge-ort.c

index 27a58a735d69bb5299498e7322e37f91b93fe360..289a61822f2314a292c38ba642b201cf67cbaab9 100644 (file)
@@ -3822,15 +3822,16 @@ static int tree_entry_order(const void *a_, const void *b_)
                                 b->string, strlen(b->string), bmi->result.mode);
 }
 
-static int write_tree(struct object_id *result_oid,
+static int write_tree(struct repository *repo,
+                     struct object_id *result_oid,
                      struct string_list *versions,
-                     unsigned int offset,
-                     size_t hash_size)
+                     unsigned int offset)
 {
        size_t maxlen = 0, extra;
        unsigned int nr;
        struct strbuf buf = STRBUF_INIT;
        int i, ret = 0;
+       size_t hash_size = repo->hash_algo->rawsz;
 
        assert(offset <= versions->nr);
        nr = versions->nr - offset;
@@ -3856,7 +3857,7 @@ static int write_tree(struct object_id *result_oid,
        }
 
        /* Write this object file out, and record in result_oid */
-       if (odb_write_object(the_repository->objects, buf.buf,
+       if (odb_write_object(repo->objects, buf.buf,
                             buf.len, OBJ_TREE, result_oid))
                ret = -1;
        strbuf_release(&buf);
@@ -4026,8 +4027,8 @@ static int write_completed_directory(struct merge_options *opt,
                dir_info->is_null = 0;
                dir_info->result.mode = S_IFDIR;
                if (record_tree &&
-                   write_tree(&dir_info->result.oid, &info->versions, offset,
-                              opt->repo->hash_algo->rawsz) < 0)
+                   write_tree(opt->repo, &dir_info->result.oid, &info->versions,
+                              offset) < 0)
                        ret = -1;
        }
 
@@ -4573,8 +4574,7 @@ static int process_entries(struct merge_options *opt,
                BUG("dir_metadata accounting completely off; shouldn't happen");
        }
        if (record_tree &&
-           write_tree(result_oid, &dir_metadata.versions, 0,
-                      opt->repo->hash_algo->rawsz) < 0)
+           write_tree(opt->repo, result_oid, &dir_metadata.versions, 0) < 0)
                ret = -1;
 cleanup:
        string_list_clear(&plist, 0);