reachable: report precise timestamps from objects in cruft packs
When generating a cruft pack, the caller within pack-objects will want to know the precise timestamps of cruft objects (i.e., their corresponding values in the .mtimes table) rather than the mtime of the cruft pack itself. Teach add_recent_packed() to lookup each object's precise mtime from the .mtimes file if one exists (indicated by the is_cruft bit on the packed_git structure). A couple of small things worth noting here: - load_pack_mtimes() needs to be called before asking for nth_packed_mtime(), and that call is done lazily here. That function exits early if the .mtimes file has already been opened and parsed, so only the first call is slow. - Checking the is_cruft bit can be done without any extra work on the caller's behalf, since it is set up for us automatically as a side-effect of calling add_packed_git() (just like the 'pack_keep' and 'pack_promisor' bits). Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
2fb90409b8
commit
fb546d6e43
@ -13,6 +13,7 @@
|
|||||||
#include "worktree.h"
|
#include "worktree.h"
|
||||||
#include "object-store.h"
|
#include "object-store.h"
|
||||||
#include "pack-bitmap.h"
|
#include "pack-bitmap.h"
|
||||||
|
#include "pack-mtimes.h"
|
||||||
|
|
||||||
struct connectivity_progress {
|
struct connectivity_progress {
|
||||||
struct progress *progress;
|
struct progress *progress;
|
||||||
@ -155,6 +156,7 @@ static int add_recent_packed(const struct object_id *oid,
|
|||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
struct object *obj;
|
struct object *obj;
|
||||||
|
timestamp_t mtime = p->mtime;
|
||||||
|
|
||||||
if (!want_recent_object(data, oid))
|
if (!want_recent_object(data, oid))
|
||||||
return 0;
|
return 0;
|
||||||
@ -163,7 +165,12 @@ static int add_recent_packed(const struct object_id *oid,
|
|||||||
|
|
||||||
if (obj && obj->flags & SEEN)
|
if (obj && obj->flags & SEEN)
|
||||||
return 0;
|
return 0;
|
||||||
add_recent_object(oid, p, nth_packed_object_offset(p, pos), p->mtime, data);
|
if (p->is_cruft) {
|
||||||
|
if (load_pack_mtimes(p) < 0)
|
||||||
|
die(_("could not load cruft pack .mtimes"));
|
||||||
|
mtime = nth_packed_mtime(p, pos);
|
||||||
|
}
|
||||||
|
add_recent_object(oid, p, nth_packed_object_offset(p, pos), mtime, data);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user