graph: extract logic for moving to GRAPH_PRE_COMMIT state
This computation is repeated in a couple of places and I need to add another condition to it to implement a further improvement to the graph rendering, so I'm extracting this into a function. Signed-off-by: James Coglan <jcoglan@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
46ba2abdfa
commit
ee7abb5ffa
12
graph.c
12
graph.c
@ -588,6 +588,12 @@ static void graph_update_columns(struct git_graph *graph)
|
|||||||
graph->mapping_size--;
|
graph->mapping_size--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int graph_needs_pre_commit_line(struct git_graph *graph)
|
||||||
|
{
|
||||||
|
return graph->num_parents >= 3 &&
|
||||||
|
graph->commit_index < (graph->num_columns - 1);
|
||||||
|
}
|
||||||
|
|
||||||
void graph_update(struct git_graph *graph, struct commit *commit)
|
void graph_update(struct git_graph *graph, struct commit *commit)
|
||||||
{
|
{
|
||||||
struct commit_list *parent;
|
struct commit_list *parent;
|
||||||
@ -643,8 +649,7 @@ void graph_update(struct git_graph *graph, struct commit *commit)
|
|||||||
*/
|
*/
|
||||||
if (graph->state != GRAPH_PADDING)
|
if (graph->state != GRAPH_PADDING)
|
||||||
graph->state = GRAPH_SKIP;
|
graph->state = GRAPH_SKIP;
|
||||||
else if (graph->num_parents >= 3 &&
|
else if (graph_needs_pre_commit_line(graph))
|
||||||
graph->commit_index < (graph->num_columns - 1))
|
|
||||||
graph->state = GRAPH_PRE_COMMIT;
|
graph->state = GRAPH_PRE_COMMIT;
|
||||||
else
|
else
|
||||||
graph->state = GRAPH_COMMIT;
|
graph->state = GRAPH_COMMIT;
|
||||||
@ -714,8 +719,7 @@ static void graph_output_skip_line(struct git_graph *graph, struct graph_line *l
|
|||||||
*/
|
*/
|
||||||
graph_line_addstr(line, "...");
|
graph_line_addstr(line, "...");
|
||||||
|
|
||||||
if (graph->num_parents >= 3 &&
|
if (graph_needs_pre_commit_line(graph))
|
||||||
graph->commit_index < (graph->num_columns - 1))
|
|
||||||
graph_update_state(graph, GRAPH_PRE_COMMIT);
|
graph_update_state(graph, GRAPH_PRE_COMMIT);
|
||||||
else
|
else
|
||||||
graph_update_state(graph, GRAPH_COMMIT);
|
graph_update_state(graph, GRAPH_COMMIT);
|
||||||
|
Loading…
Reference in New Issue
Block a user