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>
Adam Simpkins committed
May 25, 2008 at 00:07 UTC
7528f27dd677bed65d758667a621034b853595b4
6 files changed
+49
-41
Documentation/technical/api-history-graph.txt
+1
-1
@@ -115,7 +115,7 @@ Sample usage
115
116
------------
117
struct commit *commit;
118
-struct git_graph *graph = graph_init();
118
+struct git_graph *graph = graph_init(opts);
119
120
while ((commit = get_revision(opts)) != NULL) {
121
graph_update(graph, commit);
builtin-rev-list.c
+12
-9
@@ -65,15 +65,18 @@ static void show_commit(struct commit *commit)
65
printf("%lu ", commit->date);
66
if (header_prefix)
67
fputs(header_prefix, stdout);
68
- if (commit->object.flags & BOUNDARY)
69
- putchar('-');
70
- else if (commit->object.flags & UNINTERESTING)
71
- putchar('^');
72
- else if (revs.left_right) {
73
- if (commit->object.flags & SYMMETRIC_LEFT)
74
- putchar('<');
75
- else
76
- putchar('>');
68
+
69
+ if (!revs.graph) {
70
+ if (commit->object.flags & BOUNDARY)
71
+ putchar('-');
72
+ else if (commit->object.flags & UNINTERESTING)
73
+ putchar('^');
74
+ else if (revs.left_right) {
75
+ if (commit->object.flags & SYMMETRIC_LEFT)
76
+ putchar('<');
77
+ else
78
+ putchar('>');
79
+ }
80
}
81
if (revs.abbrev_commit && revs.abbrev)
82
fputs(find_unique_abbrev(commit->object.sha1, revs.abbrev),
graph.c
+11
-11
@@ -54,6 +54,8 @@ struct git_graph {
54
* The commit currently being processed
55
*/
56
struct commit *commit;
57
+ /* The rev-info used for the current traversal */
58
+ struct rev_info *revs;
59
/*
60
* The number of interesting parents that this commit has.
61
*
@@ -127,10 +129,11 @@ struct git_graph {
129
int *new_mapping;
130
};
131
130
-struct git_graph *graph_init(void)
132
+struct git_graph *graph_init(struct rev_info *opt)
133
{
134
struct git_graph *graph = xmalloc(sizeof(struct git_graph));
135
graph->commit = NULL;
136
+ graph->revs = opt;
137
graph->num_parents = 0;
138
graph->expansion_row = 0;
139
graph->state = GRAPH_PADDING;
@@ -565,16 +568,13 @@ void graph_output_commit_line(struct git_graph *graph, struct strbuf *sb)
568
569
if (col_commit == graph->commit) {
570
seen_this = 1;
568
- /*
569
- * If the commit has more than 1 interesting
570
- * parent, print 'M' to indicate that it is a
571
- * merge. Otherwise, print '*'.
572
- *
573
- * Note that even if this is actually a merge
574
- * commit, we still print '*' if less than 2 of its
575
- * parents are interesting.
576
- */
577
- if (graph->num_parents > 1)
571
+
572
+ if (graph->revs && graph->revs->left_right) {
573
+ if (graph->commit->object.flags & SYMMETRIC_LEFT)
574
+ strbuf_addch(sb, '<');
575
+ else
576
+ strbuf_addch(sb, '>');
577
+ } else if (graph->num_parents > 1)
578
strbuf_addch(sb, 'M');
579
else
580
strbuf_addch(sb, '*');
graph.h
+1
-1
@@ -8,7 +8,7 @@ struct git_graph;
8
* Create a new struct git_graph.
9
* The graph should be freed with graph_release() when no longer needed.
10
*/
11
-struct git_graph *graph_init();
11
+struct git_graph *graph_init(struct rev_info *opt);
12
13
/*
14
* Destroy a struct git_graph and free associated memory.
log-tree.c
+23
-18
@@ -228,15 +228,17 @@ void show_log(struct rev_info *opt)
228
if (!opt->verbose_header) {
229
graph_show_commit(opt->graph);
230
231
- if (commit->object.flags & BOUNDARY)
232
- putchar('-');
233
- else if (commit->object.flags & UNINTERESTING)
234
- putchar('^');
235
- else if (opt->left_right) {
236
- if (commit->object.flags & SYMMETRIC_LEFT)
237
- putchar('<');
238
- else
239
- putchar('>');
231
+ if (!opt->graph) {
232
+ if (commit->object.flags & BOUNDARY)
233
+ putchar('-');
234
+ else if (commit->object.flags & UNINTERESTING)
235
+ putchar('^');
236
+ else if (opt->left_right) {
237
+ if (commit->object.flags & SYMMETRIC_LEFT)
238
+ putchar('<');
239
+ else
240
+ putchar('>');
241
+ }
242
}
243
fputs(diff_unique_abbrev(commit->object.sha1, abbrev_commit), stdout);
244
if (opt->print_parents)
@@ -293,15 +295,18 @@ void show_log(struct rev_info *opt)
295
fputs(diff_get_color_opt(&opt->diffopt, DIFF_COMMIT), stdout);
296
if (opt->commit_format != CMIT_FMT_ONELINE)
297
fputs("commit ", stdout);
296
- if (commit->object.flags & BOUNDARY)
297
- putchar('-');
298
- else if (commit->object.flags & UNINTERESTING)
299
- putchar('^');
300
- else if (opt->left_right) {
301
- if (commit->object.flags & SYMMETRIC_LEFT)
302
- putchar('<');
303
- else
304
- putchar('>');
298
+
299
+ if (!opt->graph) {
300
+ if (commit->object.flags & BOUNDARY)
301
+ putchar('-');
302
+ else if (commit->object.flags & UNINTERESTING)
303
+ putchar('^');
304
+ else if (opt->left_right) {
305
+ if (commit->object.flags & SYMMETRIC_LEFT)
306
+ putchar('<');
307
+ else
308
+ putchar('>');
309
+ }
310
}
311
fputs(diff_unique_abbrev(commit->object.sha1, abbrev_commit),
312
stdout);
revision.c
+1
-1
@@ -1205,7 +1205,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
1205
if (!prefixcmp(arg, "--graph")) {
1206
revs->topo_order = 1;
1207
revs->rewrite_parents = 1;
1208
- revs->graph = graph_init();
1208
+ revs->graph = graph_init(revs);
1209
continue;
1210
}
1211
if (!strcmp(arg, "--root")) {