4 * Copyright (C) Linus Torvalds, 2005
9 * Some arguments are relevant "revision" arguments,
10 * others are about output format or other details.
11 * This sorts it all out.
13 static int is_rev_argument(const char *arg
)
15 static const char *rev_args
[] = {
22 const char **p
= rev_args
;
25 const char *str
= *p
++;
30 if (!strncmp(arg
, str
, len
))
35 int main(int argc
, char **argv
)
37 int i
, as_is
= 0, revs_only
= 0, no_revs
= 0;
39 unsigned char sha1
[20];
41 for (i
= 1; i
< argc
; i
++) {
50 if (!strcmp(arg
, "--")) {
59 if (!strcmp(arg
, "--default")) {
66 if (!strcmp(arg
, "--revs-only")) {
70 if (!strcmp(arg
, "--no-revs")) {
74 if (revs_only
| no_revs
) {
75 if (is_rev_argument(arg
) != revs_only
)
81 if (!get_sha1(arg
, sha1
)) {
85 printf("%s\n", sha1_to_hex(sha1
));
88 if (*arg
== '^' && !get_sha1(arg
+1, sha1
)) {
92 printf("^%s\n", sha1_to_hex(sha1
));
95 dotdot
= strstr(arg
, "..");
97 unsigned char end
[20];
100 if (!get_sha1(arg
, sha1
)) {
103 if (!get_sha1(n
, end
)) {
107 printf("%s\n", sha1_to_hex(end
));
108 printf("^%s\n", sha1_to_hex(sha1
));