git-p4: fix typos
[git/gitster.git] / t / helper / test-pack-mtimes.c
blobf8f9afbb5b1f57b09abf41359dbeb5e418343ab8
1 #define USE_THE_REPOSITORY_VARIABLE
3 #include "test-tool.h"
4 #include "hex.h"
5 #include "strbuf.h"
6 #include "object-store-ll.h"
7 #include "packfile.h"
8 #include "pack-mtimes.h"
9 #include "setup.h"
11 static void dump_mtimes(struct packed_git *p)
13 uint32_t i;
14 if (load_pack_mtimes(p) < 0)
15 die("could not load pack .mtimes");
17 for (i = 0; i < p->num_objects; i++) {
18 struct object_id oid;
19 if (nth_packed_object_id(&oid, p, i) < 0)
20 die("could not load object id at position %"PRIu32, i);
22 printf("%s %"PRIu32"\n",
23 oid_to_hex(&oid), nth_packed_mtime(p, i));
27 static const char *pack_mtimes_usage = "\n"
28 " test-tool pack-mtimes <pack-name.mtimes>";
30 int cmd__pack_mtimes(int argc, const char **argv)
32 struct strbuf buf = STRBUF_INIT;
33 struct packed_git *p;
35 setup_git_directory();
37 if (argc != 2)
38 usage(pack_mtimes_usage);
40 for (p = get_all_packs(the_repository); p; p = p->next) {
41 strbuf_addstr(&buf, basename(p->pack_name));
42 strbuf_strip_suffix(&buf, ".pack");
43 strbuf_addstr(&buf, ".mtimes");
45 if (!strcmp(buf.buf, argv[1]))
46 break;
48 strbuf_reset(&buf);
51 strbuf_release(&buf);
53 if (!p)
54 die("could not find pack '%s'", argv[1]);
56 dump_mtimes(p);
58 return 0;