git/t/helper/test-pack-mtimes.c
Elijah Newren a034e9106f object-store-ll.h: split this header out of object-store.h
The vast majority of files including object-store.h did not need dir.h
nor khash.h.  Split the header into two files, and let most just depend
upon object-store-ll.h, while letting the two callers that need it
depend on the full object-store.h.

After this patch:
    $ git grep -h include..object-store | sort | uniq -c
          2 #include "object-store.h"
        129 #include "object-store-ll.h"

Diff best viewed with `--color-moved`.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2023-06-21 13:39:54 -07:00

58 lines
1.1 KiB
C

#include "test-tool.h"
#include "hex.h"
#include "strbuf.h"
#include "object-store-ll.h"
#include "packfile.h"
#include "pack-mtimes.h"
#include "setup.h"
static void dump_mtimes(struct packed_git *p)
{
uint32_t i;
if (load_pack_mtimes(p) < 0)
die("could not load pack .mtimes");
for (i = 0; i < p->num_objects; i++) {
struct object_id oid;
if (nth_packed_object_id(&oid, p, i) < 0)
die("could not load object id at position %"PRIu32, i);
printf("%s %"PRIu32"\n",
oid_to_hex(&oid), nth_packed_mtime(p, i));
}
}
static const char *pack_mtimes_usage = "\n"
" test-tool pack-mtimes <pack-name.mtimes>";
int cmd__pack_mtimes(int argc, const char **argv)
{
struct strbuf buf = STRBUF_INIT;
struct packed_git *p;
setup_git_directory();
if (argc != 2)
usage(pack_mtimes_usage);
for (p = get_all_packs(the_repository); p; p = p->next) {
strbuf_addstr(&buf, basename(p->pack_name));
strbuf_strip_suffix(&buf, ".pack");
strbuf_addstr(&buf, ".mtimes");
if (!strcmp(buf.buf, argv[1]))
break;
strbuf_reset(&buf);
}
strbuf_release(&buf);
if (!p)
die("could not find pack '%s'", argv[1]);
dump_mtimes(p);
return 0;
}