| 354 | } |
| 355 | |
| 356 | struct git_graph *graph_init(struct rev_info *opt) |
| 357 | { |
| 358 | struct git_graph *graph = xmalloc(sizeof(struct git_graph)); |
| 359 | |
| 360 | if (!column_colors) { |
| 361 | char *string; |
| 362 | if (repo_config_get_string(opt->repo, "log.graphcolors", &string)) { |
| 363 | /* not configured -- use default */ |
| 364 | graph_set_column_colors(column_colors_ansi, |
| 365 | column_colors_ansi_max); |
| 366 | } else { |
| 367 | static struct strvec custom_colors = STRVEC_INIT; |
| 368 | strvec_clear(&custom_colors); |
| 369 | parse_graph_colors_config(&custom_colors, string); |
| 370 | free(string); |
| 371 | /* graph_set_column_colors takes a max-index, not a count */ |
| 372 | graph_set_column_colors(custom_colors.v, |
| 373 | custom_colors.nr - 1); |
| 374 | } |
| 375 | } |
| 376 | |
| 377 | graph->commit = NULL; |
| 378 | graph->revs = opt; |
| 379 | graph->num_parents = 0; |
| 380 | graph->expansion_row = 0; |
| 381 | graph->state = GRAPH_PADDING; |
| 382 | graph->prev_state = GRAPH_PADDING; |
| 383 | graph->commit_index = 0; |
| 384 | graph->prev_commit_index = 0; |
| 385 | graph->merge_layout = 0; |
| 386 | graph->edges_added = 0; |
| 387 | graph->prev_edges_added = 0; |
| 388 | graph->num_columns = 0; |
| 389 | graph->num_new_columns = 0; |
| 390 | graph->mapping_size = 0; |
| 391 | /* |
| 392 | * Start the column color at the maximum value, since we'll |
| 393 | * always increment it for the first commit we output. |
| 394 | * This way we start at 0 for the first commit. |
| 395 | */ |
| 396 | graph->default_column_color = column_colors_max - 1; |
| 397 | |
| 398 | /* |
| 399 | * Allocate a reasonably large default number of columns |
| 400 | * We'll automatically grow columns later if we need more room. |
| 401 | */ |
| 402 | graph->column_capacity = 30; |
| 403 | ALLOC_ARRAY(graph->columns, graph->column_capacity); |
| 404 | ALLOC_ARRAY(graph->new_columns, graph->column_capacity); |
| 405 | ALLOC_ARRAY(graph->mapping, 2 * graph->column_capacity); |
| 406 | ALLOC_ARRAY(graph->old_mapping, 2 * graph->column_capacity); |
| 407 | |
| 408 | /* |
| 409 | * The diff output prefix callback, with this we can make |
| 410 | * all the diff output to align with the graph lines. |
| 411 | */ |
| 412 | strbuf_init(&graph->prefix_buf, 0); |
| 413 | opt->diffopt.output_prefix = diff_output_prefix_callback; |
no test coverage detected