From 9d2d87286d4dbe502df81e04ae1ba18c1ffe4831 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Tue, 22 Apr 2008 12:57:02 +0200 Subject: [PATCH] blame: simplify handling of incomplete commit information Always wait for the final blame information (the commit filename) to be read before showing any commit information. --- tig.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/tig.c b/tig.c index 8affff1..88e3220 100644 --- a/tig.c +++ b/tig.c @@ -3603,12 +3603,17 @@ static bool blame_draw(struct view *view, struct line *line, unsigned int lineno) { struct blame *blame = line->data; + struct tm *time = NULL; + char *id = NULL, *author = NULL; int col = 0; - if (opt_date) { - struct tm *time = blame->commit && *blame->commit->filename - ? &blame->commit->time : NULL; + if (blame->commit && *blame->commit->filename) { + id = blame->commit->id; + author = blame->commit->author; + time = &blame->commit->time; + } + if (opt_date) { col += draw_date(view, time, view->width); if (col >= view->width) return TRUE; @@ -3618,8 +3623,8 @@ blame_draw(struct view *view, struct line *line, unsigned int lineno) int max = MIN(AUTHOR_COLS - 1, view->width - col); set_view_attr(view, LINE_MAIN_AUTHOR); - if (blame->commit) - draw_text(view, LINE_MAIN_AUTHOR, blame->commit->author, max, TRUE); + if (author) + draw_text(view, LINE_MAIN_AUTHOR, author, max, TRUE); col += AUTHOR_COLS; if (col >= view->width) return TRUE; @@ -3630,8 +3635,8 @@ blame_draw(struct view *view, struct line *line, unsigned int lineno) int max = MIN(ID_COLS - 1, view->width - col); set_view_attr(view, LINE_BLAME_ID); - if (blame->commit) - draw_text(view, LINE_BLAME_ID, blame->commit->id, max, FALSE); + if (id) + draw_text(view, LINE_BLAME_ID, id, max, FALSE); col += ID_COLS; if (col >= view->width) return TRUE; -- 2.30.2