4 static const char rev_list_usage[] =
5 "usage: git-rev-list [OPTION] commit-id <commit-id>\n"
11 int main(int argc, char **argv)
14 unsigned char sha1[2][20];
15 struct commit_list *list = NULL;
16 struct commit *commit, *end;
17 int i, verbose_header = 0;
18 unsigned long max_age = -1;
19 unsigned long min_age = -1;
23 for (i = 1 ; i < argc; i++) {
26 if (!strncmp(arg, "--max-count=", 12)) {
27 max_count = atoi(arg + 12);
30 if (!strncmp(arg, "--max-age=", 10)) {
31 max_age = atoi(arg + 10);
34 if (!strncmp(arg, "--min-age=", 10)) {
35 min_age = atoi(arg + 10);
38 if (!strcmp(arg, "--header")) {
43 if (nr_sha > 2 || get_sha1(arg, sha1[nr_sha]))
44 usage(rev_list_usage);
49 usage(rev_list_usage);
51 commit = lookup_commit_reference(sha1[0]);
52 if (!commit || parse_commit(commit) < 0)
53 die("bad starting commit object");
57 end = lookup_commit_reference(sha1[1]);
58 if (!end || parse_commit(end) < 0)
59 die("bad ending commit object");
62 commit_list_insert(commit, &list);
64 struct commit *commit = pop_most_recent_commit(&list, 0x1);
68 if (min_age != -1 && (commit->date > min_age))
70 if (max_age != -1 && (commit->date < max_age))
72 if (max_count != -1 && !max_count--)
74 printf("%s\n", sha1_to_hex(commit->object.sha1));
76 printf("%s%c", commit->buffer, 0);