git-rev-list: add "--parents" command line flag
It makes rev-list show the list of parents, the same way git-rev-tree does (but without the expense).maint
parent
8906300f65
commit
97658004c3
16
rev-list.c
16
rev-list.c
|
@ -41,7 +41,7 @@ int main(int argc, char **argv)
|
||||||
unsigned char sha1[2][20];
|
unsigned char sha1[2][20];
|
||||||
struct commit_list *list = NULL;
|
struct commit_list *list = NULL;
|
||||||
struct commit *commit, *end;
|
struct commit *commit, *end;
|
||||||
int i, verbose_header = 0;
|
int i, verbose_header = 0, show_parents = 0;
|
||||||
unsigned long max_age = -1;
|
unsigned long max_age = -1;
|
||||||
unsigned long min_age = -1;
|
unsigned long min_age = -1;
|
||||||
int max_count = -1;
|
int max_count = -1;
|
||||||
|
@ -66,6 +66,10 @@ int main(int argc, char **argv)
|
||||||
verbose_header = 1;
|
verbose_header = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (!strcmp(arg, "--parents")) {
|
||||||
|
show_parents = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (nr_sha > 2 || get_sha1(arg, sha1[nr_sha]))
|
if (nr_sha > 2 || get_sha1(arg, sha1[nr_sha]))
|
||||||
usage(rev_list_usage);
|
usage(rev_list_usage);
|
||||||
|
@ -116,7 +120,15 @@ int main(int argc, char **argv)
|
||||||
break;
|
break;
|
||||||
if (max_count != -1 && !max_count--)
|
if (max_count != -1 && !max_count--)
|
||||||
break;
|
break;
|
||||||
printf("%s\n", sha1_to_hex(commit->object.sha1));
|
printf("%s", sha1_to_hex(commit->object.sha1));
|
||||||
|
if (show_parents) {
|
||||||
|
struct commit_list *parents = commit->parents;
|
||||||
|
while (parents) {
|
||||||
|
printf(" %s", sha1_to_hex(parents->item->object.sha1));
|
||||||
|
parents = parents->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
putchar('\n');
|
||||||
if (verbose_header)
|
if (verbose_header)
|
||||||
printf("%s%c", commit->buffer, 0);
|
printf("%s%c", commit->buffer, 0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue