summaryrefslogtreecommitdiffstats
path: root/object-file.c
diff options
context:
space:
mode:
authorTaylor Blau <me@ttaylorr.com>2022-05-21 01:18:17 +0200
committerJunio C Hamano <gitster@pobox.com>2022-05-27 00:48:26 +0200
commita613164257b46700ca583bdcab160c712ad392fe (patch)
treeaccfaffaf186a44568b88aeca58ffd03b50e1e21 /object-file.c
parentbuiltin/gc.c: conditionally avoid pruning objects via loose (diff)
downloadgit-a613164257b46700ca583bdcab160c712ad392fe.tar.xz
git-a613164257b46700ca583bdcab160c712ad392fe.zip
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>
Diffstat (limited to 'object-file.c')
-rw-r--r--object-file.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/object-file.c b/object-file.c
index ff0cffe68e..495a359200 100644
--- a/object-file.c
+++ b/object-file.c
@@ -2035,6 +2035,8 @@ static int freshen_packed_object(const struct object_id *oid)
struct pack_entry e;
if (!find_pack_entry(the_repository, oid, &e))
return 0;
+ if (e.p->is_cruft)
+ return 0;
if (e.p->freshened)
return 1;
if (!freshen_file(e.p->pack_name))