]> git.ipfire.org Git - thirdparty/git.git/blame - t/helper/test-pack-mtimes.c
Merge branch 'ob/t9001-indent-fix'
[thirdparty/git.git] / t / helper / test-pack-mtimes.c
CommitLineData
2bd44278 1#include "test-tool.h"
41771fa4 2#include "hex.h"
2bd44278 3#include "strbuf.h"
a034e910 4#include "object-store-ll.h"
2bd44278
TB
5#include "packfile.h"
6#include "pack-mtimes.h"
e38da487 7#include "setup.h"
2bd44278
TB
8
9static void dump_mtimes(struct packed_git *p)
10{
11 uint32_t i;
12 if (load_pack_mtimes(p) < 0)
13 die("could not load pack .mtimes");
14
15 for (i = 0; i < p->num_objects; i++) {
16 struct object_id oid;
17 if (nth_packed_object_id(&oid, p, i) < 0)
18 die("could not load object id at position %"PRIu32, i);
19
20 printf("%s %"PRIu32"\n",
21 oid_to_hex(&oid), nth_packed_mtime(p, i));
22 }
23}
24
25static const char *pack_mtimes_usage = "\n"
26" test-tool pack-mtimes <pack-name.mtimes>";
27
28int cmd__pack_mtimes(int argc, const char **argv)
29{
30 struct strbuf buf = STRBUF_INIT;
31 struct packed_git *p;
32
33 setup_git_directory();
34
35 if (argc != 2)
36 usage(pack_mtimes_usage);
37
38 for (p = get_all_packs(the_repository); p; p = p->next) {
39 strbuf_addstr(&buf, basename(p->pack_name));
40 strbuf_strip_suffix(&buf, ".pack");
41 strbuf_addstr(&buf, ".mtimes");
42
43 if (!strcmp(buf.buf, argv[1]))
44 break;
45
46 strbuf_reset(&buf);
47 }
48
49 strbuf_release(&buf);
50
51 if (!p)
52 die("could not find pack '%s'", argv[1]);
53
54 dump_mtimes(p);
55
56 return 0;
57}