зеркало из https://github.com/microsoft/git.git
log --graph --left-right: show left/right information in place of '*'
With the --graph option, the graph already outputs 'o' instead of '*' for boundary commits. Make it emit '<' or '>' when --left-right is specified. (This change also disables the '^' prefix for UNINTERESTING commits. The graph code currently doesn't print anything special for these commits, since it assumes no UNINTERESTING, non-BOUNDARY commits are displayed. This is potentially a bug if UNINTERESTING non-BOUNDARY commits can actually be displayed via some code path.) [jc: squashed the left-right change from Dscho and Adam's fixup into one] Signed-off-by: Adam Simpkins <adam@adamsimpkins.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
37a75abc98
Коммит
7528f27dd6
|
@ -115,7 +115,7 @@ Sample usage
|
||||||
|
|
||||||
------------
|
------------
|
||||||
struct commit *commit;
|
struct commit *commit;
|
||||||
struct git_graph *graph = graph_init();
|
struct git_graph *graph = graph_init(opts);
|
||||||
|
|
||||||
while ((commit = get_revision(opts)) != NULL) {
|
while ((commit = get_revision(opts)) != NULL) {
|
||||||
graph_update(graph, commit);
|
graph_update(graph, commit);
|
||||||
|
|
|
@ -65,6 +65,8 @@ static void show_commit(struct commit *commit)
|
||||||
printf("%lu ", commit->date);
|
printf("%lu ", commit->date);
|
||||||
if (header_prefix)
|
if (header_prefix)
|
||||||
fputs(header_prefix, stdout);
|
fputs(header_prefix, stdout);
|
||||||
|
|
||||||
|
if (!revs.graph) {
|
||||||
if (commit->object.flags & BOUNDARY)
|
if (commit->object.flags & BOUNDARY)
|
||||||
putchar('-');
|
putchar('-');
|
||||||
else if (commit->object.flags & UNINTERESTING)
|
else if (commit->object.flags & UNINTERESTING)
|
||||||
|
@ -75,6 +77,7 @@ static void show_commit(struct commit *commit)
|
||||||
else
|
else
|
||||||
putchar('>');
|
putchar('>');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (revs.abbrev_commit && revs.abbrev)
|
if (revs.abbrev_commit && revs.abbrev)
|
||||||
fputs(find_unique_abbrev(commit->object.sha1, revs.abbrev),
|
fputs(find_unique_abbrev(commit->object.sha1, revs.abbrev),
|
||||||
stdout);
|
stdout);
|
||||||
|
|
22
graph.c
22
graph.c
|
@ -54,6 +54,8 @@ struct git_graph {
|
||||||
* The commit currently being processed
|
* The commit currently being processed
|
||||||
*/
|
*/
|
||||||
struct commit *commit;
|
struct commit *commit;
|
||||||
|
/* The rev-info used for the current traversal */
|
||||||
|
struct rev_info *revs;
|
||||||
/*
|
/*
|
||||||
* The number of interesting parents that this commit has.
|
* The number of interesting parents that this commit has.
|
||||||
*
|
*
|
||||||
|
@ -127,10 +129,11 @@ struct git_graph {
|
||||||
int *new_mapping;
|
int *new_mapping;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct git_graph *graph_init(void)
|
struct git_graph *graph_init(struct rev_info *opt)
|
||||||
{
|
{
|
||||||
struct git_graph *graph = xmalloc(sizeof(struct git_graph));
|
struct git_graph *graph = xmalloc(sizeof(struct git_graph));
|
||||||
graph->commit = NULL;
|
graph->commit = NULL;
|
||||||
|
graph->revs = opt;
|
||||||
graph->num_parents = 0;
|
graph->num_parents = 0;
|
||||||
graph->expansion_row = 0;
|
graph->expansion_row = 0;
|
||||||
graph->state = GRAPH_PADDING;
|
graph->state = GRAPH_PADDING;
|
||||||
|
@ -565,16 +568,13 @@ void graph_output_commit_line(struct git_graph *graph, struct strbuf *sb)
|
||||||
|
|
||||||
if (col_commit == graph->commit) {
|
if (col_commit == graph->commit) {
|
||||||
seen_this = 1;
|
seen_this = 1;
|
||||||
/*
|
|
||||||
* If the commit has more than 1 interesting
|
if (graph->revs && graph->revs->left_right) {
|
||||||
* parent, print 'M' to indicate that it is a
|
if (graph->commit->object.flags & SYMMETRIC_LEFT)
|
||||||
* merge. Otherwise, print '*'.
|
strbuf_addch(sb, '<');
|
||||||
*
|
else
|
||||||
* Note that even if this is actually a merge
|
strbuf_addch(sb, '>');
|
||||||
* commit, we still print '*' if less than 2 of its
|
} else if (graph->num_parents > 1)
|
||||||
* parents are interesting.
|
|
||||||
*/
|
|
||||||
if (graph->num_parents > 1)
|
|
||||||
strbuf_addch(sb, 'M');
|
strbuf_addch(sb, 'M');
|
||||||
else
|
else
|
||||||
strbuf_addch(sb, '*');
|
strbuf_addch(sb, '*');
|
||||||
|
|
2
graph.h
2
graph.h
|
@ -8,7 +8,7 @@ struct git_graph;
|
||||||
* Create a new struct git_graph.
|
* Create a new struct git_graph.
|
||||||
* The graph should be freed with graph_release() when no longer needed.
|
* The graph should be freed with graph_release() when no longer needed.
|
||||||
*/
|
*/
|
||||||
struct git_graph *graph_init();
|
struct git_graph *graph_init(struct rev_info *opt);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Destroy a struct git_graph and free associated memory.
|
* Destroy a struct git_graph and free associated memory.
|
||||||
|
|
|
@ -228,6 +228,7 @@ void show_log(struct rev_info *opt)
|
||||||
if (!opt->verbose_header) {
|
if (!opt->verbose_header) {
|
||||||
graph_show_commit(opt->graph);
|
graph_show_commit(opt->graph);
|
||||||
|
|
||||||
|
if (!opt->graph) {
|
||||||
if (commit->object.flags & BOUNDARY)
|
if (commit->object.flags & BOUNDARY)
|
||||||
putchar('-');
|
putchar('-');
|
||||||
else if (commit->object.flags & UNINTERESTING)
|
else if (commit->object.flags & UNINTERESTING)
|
||||||
|
@ -238,6 +239,7 @@ void show_log(struct rev_info *opt)
|
||||||
else
|
else
|
||||||
putchar('>');
|
putchar('>');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
fputs(diff_unique_abbrev(commit->object.sha1, abbrev_commit), stdout);
|
fputs(diff_unique_abbrev(commit->object.sha1, abbrev_commit), stdout);
|
||||||
if (opt->print_parents)
|
if (opt->print_parents)
|
||||||
show_parents(commit, abbrev_commit);
|
show_parents(commit, abbrev_commit);
|
||||||
|
@ -293,6 +295,8 @@ void show_log(struct rev_info *opt)
|
||||||
fputs(diff_get_color_opt(&opt->diffopt, DIFF_COMMIT), stdout);
|
fputs(diff_get_color_opt(&opt->diffopt, DIFF_COMMIT), stdout);
|
||||||
if (opt->commit_format != CMIT_FMT_ONELINE)
|
if (opt->commit_format != CMIT_FMT_ONELINE)
|
||||||
fputs("commit ", stdout);
|
fputs("commit ", stdout);
|
||||||
|
|
||||||
|
if (!opt->graph) {
|
||||||
if (commit->object.flags & BOUNDARY)
|
if (commit->object.flags & BOUNDARY)
|
||||||
putchar('-');
|
putchar('-');
|
||||||
else if (commit->object.flags & UNINTERESTING)
|
else if (commit->object.flags & UNINTERESTING)
|
||||||
|
@ -303,6 +307,7 @@ void show_log(struct rev_info *opt)
|
||||||
else
|
else
|
||||||
putchar('>');
|
putchar('>');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
fputs(diff_unique_abbrev(commit->object.sha1, abbrev_commit),
|
fputs(diff_unique_abbrev(commit->object.sha1, abbrev_commit),
|
||||||
stdout);
|
stdout);
|
||||||
if (opt->print_parents)
|
if (opt->print_parents)
|
||||||
|
|
|
@ -1205,7 +1205,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
|
||||||
if (!prefixcmp(arg, "--graph")) {
|
if (!prefixcmp(arg, "--graph")) {
|
||||||
revs->topo_order = 1;
|
revs->topo_order = 1;
|
||||||
revs->rewrite_parents = 1;
|
revs->rewrite_parents = 1;
|
||||||
revs->graph = graph_init();
|
revs->graph = graph_init(revs);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!strcmp(arg, "--root")) {
|
if (!strcmp(arg, "--root")) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче