From 999e3b555764c3d76f4e06e947655db52978cd08 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Tue, 10 Apr 2012 13:01:48 -0400 Subject: [PATCH] Refactor main_add_commit from main_read --- tig.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/tig.c b/tig.c index 1dc7bd6..85d9916 100644 --- a/tig.c +++ b/tig.c @@ -6577,6 +6577,23 @@ struct commit { struct graph_canvas graph; /* Ancestry chain graphics. */ }; +static struct commit * +main_add_commit(struct view *view, enum line_type type, const char *ids, bool is_boundary) +{ + struct graph *graph = view->private; + struct commit *commit; + + commit = calloc(1, sizeof(struct commit)); + if (!commit) + return NULL; + + string_copy_rev(commit->id, ids); + commit->refs = get_ref_list(commit->id); + add_line_data(view, commit, type); + graph_add_commit(graph, &commit->graph, commit->id, ids, is_boundary); + return commit; +} + static bool main_open(struct view *view, enum open_flags flags) { @@ -6644,20 +6661,12 @@ main_read(struct view *view, char *line) if (type == LINE_COMMIT) { bool is_boundary; - commit = calloc(1, sizeof(struct commit)); - if (!commit) - return FALSE; - line += STRING_SIZE("commit "); is_boundary = *line == '-'; if (is_boundary) line++; - string_copy_rev(commit->id, line); - commit->refs = get_ref_list(commit->id); - add_line_data(view, commit, LINE_MAIN_COMMIT); - graph_add_commit(graph, &commit->graph, commit->id, line, is_boundary); - return TRUE; + return main_add_commit(view, LINE_MAIN_COMMIT, line, is_boundary) != NULL; } if (!view->lines) -- 2.11.4.GIT