From c53a518939bc71fdb60b0e6a69a74e55b358c3fe Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Thu, 24 Apr 2014 21:12:57 -0400 Subject: [PATCH] Add reflog member to the column_data struct This way the ID width calculation does not have to guess if the ID is a SHA1 or a reflog ID. --- include/tig/view.h | 1 + src/draw.c | 2 +- src/main.c | 5 ++--- src/view.c | 6 ++++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/include/tig/view.h b/include/tig/view.h index ee8e294..2930a8c 100644 --- a/include/tig/view.h +++ b/include/tig/view.h @@ -178,6 +178,7 @@ struct view_column_data { const unsigned long *line_number; const mode_t *mode; const struct ref *ref; + const char *reflog; const struct ref_list *refs; const char *status; const char *text; diff --git a/src/draw.c b/src/draw.c index e10c177..47d7b7f 100644 --- a/src/draw.c +++ b/src/draw.c @@ -503,7 +503,7 @@ view_column_draw(struct view *view, struct line *line, unsigned int lineno) continue; case VIEW_COLUMN_ID: - if (draw_id(view, column, column_data.id)) + if (draw_id(view, column, column_data.reflog ? column_data.reflog : column_data.id)) return TRUE; continue; diff --git a/src/main.c b/src/main.c index 225ac03..2303805 100644 --- a/src/main.c +++ b/src/main.c @@ -246,10 +246,9 @@ main_get_column_data(struct view *view, const struct line *line, struct view_col column_data->author = commit->author; column_data->date = &commit->time; + column_data->id = commit->id; if (state->reflogs) - column_data->id = state->reflog[line->lineno - 1]; - else - column_data->id = commit->id; + column_data->reflog = state->reflog[line->lineno - 1]; column_data->commit_title = commit->title; if (state->with_graph) diff --git a/src/view.c b/src/view.c index 8b38bf6..4525744 100644 --- a/src/view.c +++ b/src/view.c @@ -891,6 +891,8 @@ sort_view_compare(const void *l1, const void *l2) return sort_order(sort, timecmp, column_data1.date, column_data2.date); case VIEW_COLUMN_ID: + if (column_data1.reflog && column_data2.reflog) + return sort_order(sort, strcmp, column_data1.reflog, column_data2.reflog); return sort_order(sort, strcmp, column_data1.id, column_data2.id); case VIEW_COLUMN_FILE_NAME: @@ -987,7 +989,7 @@ view_column_text(struct view *view, struct view_column_data *column_data, case VIEW_COLUMN_ID: if (column->opt.id.show) - text = column_data->id; + text = column_data->reflog ? column_data->reflog : column_data->id; break; case VIEW_COLUMN_LINE_NUMBER: @@ -1296,7 +1298,7 @@ view_column_info_update(struct view *view, struct line *line) width = column->opt.id.width; if (!width) width = opt_id_width; - if (iscommit(text) && !width) + if (!column_data.reflog && !width) width = 7; break; -- 2.11.4.GIT