pack-mtimes: support reading .mtimes files
To store the individual mtimes of objects in a cruft pack, introduce a new `.mtimes` format that can optionally accompany a single pack in the repository. The format is defined in Documentation/technical/pack-format.txt, and stores a 4-byte network order timestamp for each object in name (index) order. This patch prepares for cruft packs by defining the `.mtimes` format, and introducing a basic API that callers can use to read out individual mtimes. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
3d89a8c118
commit
94cd775a6c
19
packfile.c
19
packfile.c
@ -334,12 +334,22 @@ static void close_pack_revindex(struct packed_git *p)
|
||||
p->revindex_data = NULL;
|
||||
}
|
||||
|
||||
static void close_pack_mtimes(struct packed_git *p)
|
||||
{
|
||||
if (!p->mtimes_map)
|
||||
return;
|
||||
|
||||
munmap((void *)p->mtimes_map, p->mtimes_size);
|
||||
p->mtimes_map = NULL;
|
||||
}
|
||||
|
||||
void close_pack(struct packed_git *p)
|
||||
{
|
||||
close_pack_windows(p);
|
||||
close_pack_fd(p);
|
||||
close_pack_index(p);
|
||||
close_pack_revindex(p);
|
||||
close_pack_mtimes(p);
|
||||
oidset_clear(&p->bad_objects);
|
||||
}
|
||||
|
||||
@ -363,7 +373,7 @@ void close_object_store(struct raw_object_store *o)
|
||||
|
||||
void unlink_pack_path(const char *pack_name, int force_delete)
|
||||
{
|
||||
static const char *exts[] = {".pack", ".idx", ".rev", ".keep", ".bitmap", ".promisor"};
|
||||
static const char *exts[] = {".pack", ".idx", ".rev", ".keep", ".bitmap", ".promisor", ".mtimes"};
|
||||
int i;
|
||||
struct strbuf buf = STRBUF_INIT;
|
||||
size_t plen;
|
||||
@ -718,6 +728,10 @@ struct packed_git *add_packed_git(const char *path, size_t path_len, int local)
|
||||
if (!access(p->pack_name, F_OK))
|
||||
p->pack_promisor = 1;
|
||||
|
||||
xsnprintf(p->pack_name + path_len, alloc - path_len, ".mtimes");
|
||||
if (!access(p->pack_name, F_OK))
|
||||
p->is_cruft = 1;
|
||||
|
||||
xsnprintf(p->pack_name + path_len, alloc - path_len, ".pack");
|
||||
if (stat(p->pack_name, &st) || !S_ISREG(st.st_mode)) {
|
||||
free(p);
|
||||
@ -869,7 +883,8 @@ static void prepare_pack(const char *full_name, size_t full_name_len,
|
||||
ends_with(file_name, ".pack") ||
|
||||
ends_with(file_name, ".bitmap") ||
|
||||
ends_with(file_name, ".keep") ||
|
||||
ends_with(file_name, ".promisor"))
|
||||
ends_with(file_name, ".promisor") ||
|
||||
ends_with(file_name, ".mtimes"))
|
||||
string_list_append(data->garbage, full_name);
|
||||
else
|
||||
report_garbage(PACKDIR_FILE_GARBAGE, full_name);
|
||||
|
Reference in New Issue
Block a user