git-rev-list: add "--pretty" command line option
That pretty-prints the resulting commit messages, so git-rev-list --pretty HEAD v2.6.12-rc5 | less -S basically ends up being a log of the changes between -rc5 and current head. It uses the pretty-printing helper function I just extracted from diff-tree.c.
This commit is contained in:
parent
e3bc7a3bc7
commit
9d97aa6466
27
rev-list.c
27
rev-list.c
@ -10,7 +10,8 @@ static const char rev_list_usage[] =
|
|||||||
" --max-count=nr\n"
|
" --max-count=nr\n"
|
||||||
" --max-age=epoch\n"
|
" --max-age=epoch\n"
|
||||||
" --min-age=epoch\n"
|
" --min-age=epoch\n"
|
||||||
" --header";
|
" --header\n"
|
||||||
|
" --pretty";
|
||||||
|
|
||||||
static void mark_parents_uninteresting(struct commit *commit)
|
static void mark_parents_uninteresting(struct commit *commit)
|
||||||
{
|
{
|
||||||
@ -41,7 +42,9 @@ 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, show_parents = 0;
|
int i, verbose_header = 0, show_parents = 0, pretty_print = 0;
|
||||||
|
int hdr_termination = 0;
|
||||||
|
const char *prefix = "";
|
||||||
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 +69,13 @@ int main(int argc, char **argv)
|
|||||||
verbose_header = 1;
|
verbose_header = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (!strcmp(arg, "--pretty")) {
|
||||||
|
verbose_header = 1;
|
||||||
|
pretty_print = 1;
|
||||||
|
hdr_termination = '\n';
|
||||||
|
prefix = "commit ";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!strcmp(arg, "--parents")) {
|
if (!strcmp(arg, "--parents")) {
|
||||||
show_parents = 1;
|
show_parents = 1;
|
||||||
continue;
|
continue;
|
||||||
@ -120,7 +130,7 @@ int main(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
if (max_count != -1 && !max_count--)
|
if (max_count != -1 && !max_count--)
|
||||||
break;
|
break;
|
||||||
printf("%s", sha1_to_hex(commit->object.sha1));
|
printf("%s%s", prefix, sha1_to_hex(commit->object.sha1));
|
||||||
if (show_parents) {
|
if (show_parents) {
|
||||||
struct commit_list *parents = commit->parents;
|
struct commit_list *parents = commit->parents;
|
||||||
while (parents) {
|
while (parents) {
|
||||||
@ -129,8 +139,15 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
if (verbose_header)
|
if (verbose_header) {
|
||||||
printf("%s%c", commit->buffer, 0);
|
const char *buf = commit->buffer;
|
||||||
|
if (pretty_print) {
|
||||||
|
static char pretty_header[16384];
|
||||||
|
pretty_print_commit(commit->buffer, ~0, pretty_header, sizeof(pretty_header));
|
||||||
|
buf = pretty_header;
|
||||||
|
}
|
||||||
|
printf("%s%c", buf, hdr_termination);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user