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>
This commit is contained in:
committed by
Junio C Hamano
parent
1efe0aeaa2
commit
cbb388f3e5
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user