4 int main(int argc
, char **argv
)
6 unsigned char sha1
[20];
7 struct commit_list
*list
= NULL
;
9 char *commit_arg
= NULL
;
11 unsigned long max_age
= -1;
12 unsigned long min_age
= -1;
15 for (i
= 1 ; i
< argc
; i
++) {
18 if (!strncmp(arg
, "--max-count=", 12)) {
19 max_count
= atoi(arg
+ 12);
20 } else if (!strncmp(arg
, "--max-age=", 10)) {
21 max_age
= atoi(arg
+ 10);
22 } else if (!strncmp(arg
, "--min-age=", 10)) {
23 min_age
= atoi(arg
+ 10);
29 if (!commit_arg
|| get_sha1(commit_arg
, sha1
))
30 usage("usage: rev-list [OPTION] commit-id\n"
33 " --min-age=epoch\n");
35 commit
= lookup_commit(sha1
);
36 if (!commit
|| parse_commit(commit
) < 0)
37 die("bad commit object");
39 commit_list_insert(commit
, &list
);
41 struct commit
*commit
= pop_most_recent_commit(&list
, 0x1);
43 if (min_age
!= -1 && (commit
->date
> min_age
))
45 if (max_age
!= -1 && (commit
->date
< max_age
))
47 if (max_count
!= -1 && !max_count
--)
49 printf("%s\n", sha1_to_hex(commit
->object
.sha1
));