]>
Commit | Line | Data |
---|---|---|
ab176ac4 DS |
1 | #include "test-tool.h" |
2 | #include "cache.h" | |
3 | #include "commit.h" | |
4 | #include "commit-reach.h" | |
5 | #include "config.h" | |
6 | #include "parse-options.h" | |
7 | #include "tag.h" | |
8 | ||
9 | int cmd__reach(int ac, const char **av) | |
10 | { | |
11 | struct object_id oid_A, oid_B; | |
12 | struct strbuf buf = STRBUF_INIT; | |
13 | struct repository *r = the_repository; | |
14 | ||
15 | setup_git_directory(); | |
16 | ||
17 | if (ac < 2) | |
18 | exit(1); | |
19 | ||
20 | ||
21 | while (strbuf_getline(&buf, stdin) != EOF) { | |
22 | struct object_id oid; | |
23 | struct object *o; | |
24 | struct commit *c; | |
25 | if (buf.len < 3) | |
26 | continue; | |
27 | ||
28 | if (get_oid_committish(buf.buf + 2, &oid)) | |
29 | die("failed to resolve %s", buf.buf + 2); | |
30 | ||
31 | o = parse_object(r, &oid); | |
32 | o = deref_tag_noverify(o); | |
33 | ||
34 | if (!o) | |
35 | die("failed to load commit for input %s resulting in oid %s\n", | |
36 | buf.buf, oid_to_hex(&oid)); | |
37 | ||
38 | c = object_as_type(r, o, OBJ_COMMIT, 0); | |
39 | ||
40 | if (!c) | |
41 | die("failed to load commit for input %s resulting in oid %s\n", | |
42 | buf.buf, oid_to_hex(&oid)); | |
43 | ||
44 | switch (buf.buf[0]) { | |
45 | case 'A': | |
46 | oidcpy(&oid_A, &oid); | |
47 | break; | |
48 | ||
49 | case 'B': | |
50 | oidcpy(&oid_B, &oid); | |
51 | break; | |
52 | ||
53 | default: | |
54 | die("unexpected start of line: %c", buf.buf[0]); | |
55 | } | |
56 | } | |
57 | strbuf_release(&buf); | |
58 | ||
59 | if (!strcmp(av[1], "ref_newer")) | |
60 | printf("%s(A,B):%d\n", av[1], ref_newer(&oid_A, &oid_B)); | |
61 | ||
62 | exit(0); | |
63 | } |