mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
object-file: refactor freshening of objects
When writing an object that already exists in our object database we skip the write and instead only update mtimes of the object, either in its packed or loose object format. This logic is wholly contained in "object-file.c", but that file is really only concerned with loose objects. So it does not really make sense that it also contains the logic to freshen a packed object. Introduce a new `odb_freshen_object()` function that sits on the object database level and two functions `packfile_store_freshen_object()` and `odb_source_loose_freshen_object()`. Like this, the format-specific functions can be part of their respective subsystems, while the backend agnostic function to freshen an object sits at the object database layer. Note that this change also moves the logic that iterates through object sources from the object source layer into the object database layer. This change is intentional: object sources should ideally only have to worry about themselves, and coordination of different sources should be handled on the object database level. 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
05130c6c9e
commit
f2bd88a308
16
packfile.c
16
packfile.c
@@ -819,6 +819,22 @@ struct packed_git *packfile_store_load_pack(struct packfile_store *store,
|
||||
return p;
|
||||
}
|
||||
|
||||
int packfile_store_freshen_object(struct packfile_store *store,
|
||||
const struct object_id *oid)
|
||||
{
|
||||
struct pack_entry e;
|
||||
if (!find_pack_entry(store->odb->repo, oid, &e))
|
||||
return 0;
|
||||
if (e.p->is_cruft)
|
||||
return 0;
|
||||
if (e.p->freshened)
|
||||
return 1;
|
||||
if (utime(e.p->pack_name, NULL))
|
||||
return 0;
|
||||
e.p->freshened = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void (*report_garbage)(unsigned seen_bits, const char *path);
|
||||
|
||||
static void report_helper(const struct string_list *list,
|
||||
|
||||
Reference in New Issue
Block a user