]> git.ipfire.org Git - thirdparty/git.git/commit
object-file: refactor freshening of objects
authorPatrick Steinhardt <ps@pks.im>
Mon, 3 Nov 2025 07:42:06 +0000 (08:42 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 3 Nov 2025 20:18:47 +0000 (12:18 -0800)
commitf2bd88a308a2754e727cb462e03102307cdfe004
tree649bf03eceb85bb383ab05424b66d9de4a0a1e32
parent05130c6c9eed9ff7450e9067d7215032eb914c10
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>
object-file.c
object-file.h
odb.c
odb.h
packfile.c
packfile.h