Skip to content

Commit

Permalink
Naïvely color blame IDs to distinguish lines
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas committed Jun 25, 2011
1 parent be7a334 commit 87c5687
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Incompatibilities:

Improvements:

- Naïvely color blame IDs to distinguish lines.
- Add support for blaming diff lines.
- Add diff-context option and bindings to increase the diff context in
the diff and stage view.
Expand Down
16 changes: 15 additions & 1 deletion tig.c
Original file line number Diff line number Diff line change
Expand Up @@ -4577,11 +4577,25 @@ blame_draw(struct view *view, struct line *line, unsigned int lineno)
struct blame *blame = line->data;
struct time *time = NULL;
const char *id = NULL, *author = NULL;
enum line_type id_type = LINE_BLAME_ID;
static const enum line_type blame_colors[] = {
LINE_GRAPH_LINE_0,
LINE_GRAPH_LINE_1,
LINE_GRAPH_LINE_2,
LINE_GRAPH_LINE_3,
LINE_GRAPH_LINE_4,
LINE_GRAPH_LINE_5,
LINE_GRAPH_LINE_6,
};

#define BLAME_COLOR(i) \
(blame_colors[(i) % ARRAY_SIZE(blame_colors)])

if (blame->commit && *blame->commit->filename) {
id = blame->commit->id;
author = blame->commit->author;
time = &blame->commit->time;
id_type = BLAME_COLOR((long) blame->commit);
}

if (draw_date(view, time))
Expand All @@ -4590,7 +4604,7 @@ blame_draw(struct view *view, struct line *line, unsigned int lineno)
if (draw_author(view, author))
return TRUE;

if (draw_field(view, LINE_BLAME_ID, id, ID_COLS, FALSE))
if (draw_field(view, id_type, id, ID_COLS, FALSE))
return TRUE;

if (draw_lineno(view, lineno))
Expand Down

0 comments on commit 87c5687

Please sign in to comment.