]> git.ipfire.org Git - thirdparty/git.git/commit - t/t5329-pack-objects-cruft.sh
sha1-file.c: don't freshen cruft packs
authorTaylor Blau <me@ttaylorr.com>
Fri, 20 May 2022 23:18:17 +0000 (19:18 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 26 May 2022 22:48:26 +0000 (15:48 -0700)
commita613164257b46700ca583bdcab160c712ad392fe
treeaccfaffaf186a44568b88aeca58ffd03b50e1e21
parent5b92477f896f147d02bd2e9168a780940b57cfc5
sha1-file.c: don't freshen cruft packs

We don't bother to freshen objects stored in a cruft pack individually
by updating the `.mtimes` file. This is because we can't portably `mmap`
and write into the middle of a file (i.e., to update the mtime of just
one object). Instead, we would have to rewrite the entire `.mtimes` file
which may incur some wasted effort especially if there a lot of cruft
objects and they are freshened infrequently.

Instead, force the freshening code to avoid an optimizing write by
writing out the object loose and letting it pick up a current mtime.

This works because we prefer the mtime of the loose copy of an object
when both a loose and packed one exist (whether or not the packed copy
comes from a cruft pack or not).

This could certainly do with a test and/or be included earlier in this
series/PR, but I want to wait until after I have a chance to clean up
the overly-repetitive nature of the cruft pack tests in general.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
object-file.c
t/t5329-pack-objects-cruft.sh