{"thread":{"id":"20658","subject":"[PATCH] graph API: use a new color when starting a brand new column","startedAt":"2009-08-18T21:41:12Z","lastAt":"2009-08-18T21:41:12Z","messageCount":1,"participants":["Adam Simpkins"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"121170","messageId":"20090818214112.GM8147@facebook.com","threadId":"20658","inReplyTo":null,"subject":"[PATCH] graph API: use a new color when starting a brand new column","fromName":"Adam Simpkins","fromEmail":"simpkins@facebook.com","sentAt":"2009-08-18T21:41:12Z","receivedAt":"2009-08-18T21:41:12Z","isPatch":true,"sender":{"key":"simpkins@facebook.com","avatar":null},"body":"Use a new color for commits that don't have any previously printed\nchildren.  The following command demonstrates the changes:\n\n  git log --graph --pretty=tformat:'%h %s%n' -7 481c7a6 18b0793\n\nNow the two independent lines of development are displayed with\ndifferent colors, instead of both using the same color.\n\nSigned-off-by: Adam Simpkins <simpkins@facebook.com>\n---\n graph.c |   14 +++++++++++---\n 1 files changed, 11 insertions(+), 3 deletions(-)\n\ndiff --git a/graph.c b/graph.c\nindex e466770..f3226ec 100644\n--- a/graph.c\n+++ b/graph.c\n@@ -225,7 +225,12 @@ struct git_graph *graph_init(struct rev_info *opt)\n \tgraph->num_columns = 0;\n \tgraph->num_new_columns = 0;\n \tgraph->mapping_size = 0;\n-\tgraph->default_column_color = 0;\n+\t/*\n+\t * Start the column color at the maximum value, since we'll\n+\t * always increment it for the first commit we output.\n+\t * This way we start at 0 for the first commit.\n+\t */\n+\tgraph->default_column_color = COLUMN_COLORS_MAX - 1;\n \n \t/*\n \t * Allocate a reasonably large default number of columns\n@@ -499,11 +504,14 @@ static void graph_update_columns(struct git_graph *graph)\n \t\t\t     parent;\n \t\t\t     parent = next_interesting_parent(graph, parent)) {\n \t\t\t\t/*\n-\t\t\t\t * If this is a merge increment the current\n+\t\t\t\t * If this is a merge, or the start of a new\n+\t\t\t\t * childless column, increment the current\n \t\t\t\t * color.\n \t\t\t\t */\n-\t\t\t\tif (graph->num_parents > 1)\n+\t\t\t\tif (graph->num_parents > 1 ||\n+\t\t\t\t    !is_commit_in_columns) {\n \t\t\t\t\tgraph_increment_column_color(graph);\n+\t\t\t\t}\n \t\t\t\tgraph_insert_into_new_columns(graph,\n \t\t\t\t\t\t\t      parent->item,\n \t\t\t\t\t\t\t      &mapping_idx);\n-- \n1.6.4.314.g5667f\n"}]}