mirror of
https://github.com/git/git.git
synced 2026-03-04 22:47:35 +01:00
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>
This commit is contained in:
committed by
Junio C Hamano
parent
84325f0730
commit
4f8108b5ff
16
merge-ort.c
16
merge-ort.c
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user