diff options
author | Adam Simpkins <adam@adamsimpkins.net> | 2008-06-01 13:56:58 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-06-01 21:44:47 -0700 |
commit | f1979d6b3fba41fb6ca92290bf8e10d58ede8970 (patch) | |
tree | 11c35606b71b210393f25b59c3c9c578edb53352 /graph.c | |
parent | 3395908ee481e91bbe3ba054a7419b071b09cdef (diff) | |
download | git-f1979d6b3fba41fb6ca92290bf8e10d58ede8970.tar.gz |
graph API: avoid printing unnecessary padding before some octopus merges
When an octopus merge is printed, several lines are printed before it to
move over existing branch lines to its right. This is needed to make
room for the children of the octopus merge. For example:
| | | |
| | \ \
| | \ \
| | \ \
| M---. \ \
| |\ \ \ \ \
However, this step isn't necessary if there are no branch lines to the
right of the octopus merge. Therefore, skip this step when it is not
needed, to avoid printing extra lines that don't really serve any
purpose.
Signed-off-by: Adam Simpkins <adam@adamsimpkins.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'graph.c')
-rw-r--r-- | graph.c | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -450,16 +450,18 @@ void graph_update(struct git_graph *graph, struct commit *commit) * it never finished its output. Goto GRAPH_SKIP, to print out * a line to indicate that portion of the graph is missing. * - * Otherwise, if there are 3 or more parents, we need to print - * extra rows before the commit, to expand the branch lines around - * it and make room for it. + * If there are 3 or more parents, we may need to print extra rows + * before the commit, to expand the branch lines around it and make + * room for it. We need to do this only if there is a branch row + * (or more) to the right of this commit. * * If there are less than 3 parents, we can immediately print the * commit line. */ if (graph->state != GRAPH_PADDING) graph->state = GRAPH_SKIP; - else if (graph->num_parents >= 3) + else if (graph->num_parents >= 3 && + graph->commit_index < (graph->num_columns - 1)) graph->state = GRAPH_PRE_COMMIT; else graph->state = GRAPH_COMMIT; @@ -538,7 +540,8 @@ static void graph_output_skip_line(struct git_graph *graph, struct strbuf *sb) strbuf_addstr(sb, "..."); graph_pad_horizontally(graph, sb); - if (graph->num_parents >= 3) + if (graph->num_parents >= 3 && + graph->commit_index < (graph->num_columns - 1)) graph_update_state(graph, GRAPH_PRE_COMMIT); else graph_update_state(graph, GRAPH_COMMIT); |