diff options
| author | Patrick Steinhardt <ps@pks.im> | 2025-07-17 06:56:33 +0200 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-07-16 22:16:14 -0700 |
| commit | cbb388f3e53660c88220c40a8dddb976672ae03d (patch) | |
| tree | f664f87596158d4851db3931a23d3459e3d04224 /object-file.c | |
| parent | object-file: get rid of `the_repository` in `loose_object_info()` (diff) | |
| download | git-cbb388f3e53660c88220c40a8dddb976672ae03d.tar.gz git-cbb388f3e53660c88220c40a8dddb976672ae03d.zip | |
object-file: get rid of `the_repository` in `finalize_object_file()`
We implicitly depend on `the_repository` when moving an object file into
place in `finalize_object_file()`. Get rid of this global dependency by
passing in a repository.
Note that one might be pressed to inject an object database instead of a
repository. But the function doesn't really care about the ODB at all.
All it does is to move a file into place while checking whether there is
any collision. As such, the functionality it provides is independent of
the object database and only needs the repository as parameter so that
it can adjust permissions of the file we are about to finalize.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'object-file.c')
| -rw-r--r-- | object-file.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/object-file.c b/object-file.c index 800eeae85a..6a7049a9e9 100644 --- a/object-file.c +++ b/object-file.c @@ -584,12 +584,14 @@ out: /* * Move the just written object into its final resting place. */ -int finalize_object_file(const char *tmpfile, const char *filename) +int finalize_object_file(struct repository *repo, + const char *tmpfile, const char *filename) { - return finalize_object_file_flags(tmpfile, filename, 0); + return finalize_object_file_flags(repo, tmpfile, filename, 0); } -int finalize_object_file_flags(const char *tmpfile, const char *filename, +int finalize_object_file_flags(struct repository *repo, + const char *tmpfile, const char *filename, enum finalize_object_file_flags flags) { unsigned retries = 0; @@ -649,7 +651,7 @@ retry: } out: - if (adjust_shared_perm(the_repository, filename)) + if (adjust_shared_perm(repo, filename)) return error(_("unable to set permission to '%s'"), filename); return 0; } @@ -889,7 +891,7 @@ static int write_loose_object(const struct object_id *oid, char *hdr, warning_errno(_("failed utime() on %s"), tmp_file.buf); } - return finalize_object_file_flags(tmp_file.buf, filename.buf, + return finalize_object_file_flags(the_repository, tmp_file.buf, filename.buf, FOF_SKIP_COLLISION_CHECK); } @@ -1020,7 +1022,7 @@ int stream_loose_object(struct input_stream *in_stream, size_t len, strbuf_release(&dir); } - err = finalize_object_file_flags(tmp_file.buf, filename.buf, + err = finalize_object_file_flags(the_repository, tmp_file.buf, filename.buf, FOF_SKIP_COLLISION_CHECK); if (!err && compat) err = repo_add_loose_object_map(the_repository, oid, &compat_oid); |
