]> git.99rst.org Git - git.git/commit
odb: support setting mtime when writing objects
authorPatrick Steinhardt <redacted>
Fri, 17 Jul 2026 09:32:13 +0000 (11:32 +0200)
committerJunio C Hamano <redacted>
Sun, 19 Jul 2026 02:03:48 +0000 (19:03 -0700)
commit8d9135dce3be50c961f23f5e89352b0fd1d61117
tree58a0e4dd9e7925c5ad7b4fe2e0d77804f94064a7
parentb688086b8fd56e1bbab36e6bb26e12844e6e6965
odb: support setting mtime when writing objects

The function `force_object_loose()` is used to loosen packed objects
before repacking. It passes the pack's mtime along so that the newly
written loose object inherits the same timestamp. This matters for
object pruning, which uses the mtime to determine whether an object is
old enough to be pruned.

In a subsequent commit, `force_object_loose()` will be converted to use
the generic `odb_source_write_object()` interface instead of calling
`write_loose_object()` directly. But the generic interface doesn't yet
support setting a specific mtime, which makes it impossible to implement
the logic as of now.

Prepare for the change by introducing a new `mtime` parameter to this
function that we plumb through the stack. If set, the backends are
instructed to set the object's mtime accordingly. If unset, the backends
are expected to use the current time instead.

Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
builtin/pack-objects.c
object-file.c
object-file.h
odb.c
odb/source-files.c
odb/source-inmemory.c
odb/source-loose.c
odb/source-packed.c
odb/source.h
read-cache.c
t/unit-tests/u-odb-inmemory.c
git clone https://git.99rst.org/PROJECT