odb: get rid of the_repository in odb_mkstemp()

Get rid of our dependency on `the_repository` in `odb_mkstemp()` by
passing in the object database as a parameter and adjusting all callers.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt
2025-07-01 14:22:19 +02:00
committed by Junio C Hamano
parent 961038856b
commit 1b1679c688
7 changed files with 22 additions and 15 deletions

View File

@@ -84,7 +84,8 @@ const char *write_idx_file(struct repository *repo,
} else {
if (!index_name) {
struct strbuf tmp_file = STRBUF_INIT;
fd = odb_mkstemp(&tmp_file, "pack/tmp_idx_XXXXXX");
fd = odb_mkstemp(repo->objects, &tmp_file,
"pack/tmp_idx_XXXXXX");
index_name = strbuf_detach(&tmp_file, NULL);
} else {
unlink(index_name);
@@ -259,7 +260,8 @@ char *write_rev_file_order(struct repository *repo,
if (flags & WRITE_REV) {
if (!rev_name) {
struct strbuf tmp_file = STRBUF_INIT;
fd = odb_mkstemp(&tmp_file, "pack/tmp_rev_XXXXXX");
fd = odb_mkstemp(repo->objects, &tmp_file,
"pack/tmp_rev_XXXXXX");
path = strbuf_detach(&tmp_file, NULL);
} else {
unlink(rev_name);
@@ -342,7 +344,7 @@ static char *write_mtimes_file(struct repository *repo,
if (!to_pack)
BUG("cannot call write_mtimes_file with NULL packing_data");
fd = odb_mkstemp(&tmp_file, "pack/tmp_mtimes_XXXXXX");
fd = odb_mkstemp(repo->objects, &tmp_file, "pack/tmp_mtimes_XXXXXX");
mtimes_name = strbuf_detach(&tmp_file, NULL);
f = hashfd(repo->hash_algo, fd, mtimes_name);
@@ -531,7 +533,7 @@ struct hashfile *create_tmp_packfile(struct repository *repo,
struct strbuf tmpname = STRBUF_INIT;
int fd;
fd = odb_mkstemp(&tmpname, "pack/tmp_pack_XXXXXX");
fd = odb_mkstemp(repo->objects, &tmpname, "pack/tmp_pack_XXXXXX");
*pack_tmp_name = strbuf_detach(&tmpname, NULL);
return hashfd(repo->hash_algo, fd, *pack_tmp_name);
}