diff --git a/NEWS.adoc b/NEWS.adoc index 0e5000d63..d8249baaa 100644 --- a/NEWS.adoc +++ b/NEWS.adoc @@ -1,6 +1,14 @@ Release notes ============= +master +------ + +Bug fixes: + + - Fix `stat-*` coloring file names in `tig status` instead of just + markers (regression in 2.5.9). (#1326) + tig-2.5.9 --------- diff --git a/src/draw.c b/src/draw.c index c2befa472..3b960f1bd 100644 --- a/src/draw.c +++ b/src/draw.c @@ -276,10 +276,12 @@ draw_id(struct view *view, struct view_column *column, const char *id) } static bool -draw_filename(struct view *view, struct view_column *column, enum line_type type, const char *filename) +draw_filename(struct view *view, struct view_column *column, const char *filename, mode_t mode) { size_t width = filename ? utf8_width(filename) : 0; bool trim = width >= column->width; + /* Note, type for filename field is independent from line->type. */ + enum line_type type = S_ISDIR(mode) ? LINE_DIRECTORY : LINE_FILE; int column_width = column->width ? column->width : width; if (column->opt.file_name.display == FILENAME_NO) @@ -289,9 +291,9 @@ draw_filename(struct view *view, struct view_column *column, enum line_type type } static bool -draw_file_size(struct view *view, struct view_column *column, enum line_type type, unsigned long size) +draw_file_size(struct view *view, struct view_column *column, unsigned long size, mode_t mode) { - const char *str = type == LINE_FILE ? mkfilesize(size, column->opt.file_size.display) : NULL; + const char *str = S_ISREG(mode) ? mkfilesize(size, column->opt.file_size.display) : NULL; if (!column->width || column->opt.file_size.display == FILE_SIZE_NO) return false; @@ -517,7 +519,7 @@ view_column_draw(struct view *view, struct line *line, unsigned int lineno) continue; case VIEW_COLUMN_FILE_SIZE: - if (draw_file_size(view, column, line->type, column_data.file_size ? *column_data.file_size : 0)) + if (draw_file_size(view, column, column_data.file_size ? *column_data.file_size : 0, mode)) return true; continue; @@ -528,7 +530,7 @@ view_column_draw(struct view *view, struct line *line, unsigned int lineno) continue; case VIEW_COLUMN_FILE_NAME: - if (draw_filename(view, column, line->type, column_data.file_name)) + if (draw_filename(view, column, column_data.file_name, mode)) return true; continue; diff --git a/src/tree.c b/src/tree.c index e6c826f1b..e18e57bf4 100644 --- a/src/tree.c +++ b/src/tree.c @@ -212,7 +212,8 @@ tree_read(struct view *view, struct buffer *buf, bool force_stop) struct tree_state *state = view->private; struct tree_entry *data; struct line *entry, *line; - enum line_type type; + /* Note, type computed here is only used for sorting, not for drawing. */ + enum line_type type = LINE_DEFAULT; char *pos; char *mode; char *id; @@ -238,8 +239,6 @@ tree_read(struct view *view, struct buffer *buf, bool force_stop) type = LINE_FILE; else if (!strncmp(pos, "tree", STRING_SIZE("tree"))) type = LINE_DIRECTORY; - else - type = LINE_DEFAULT; /* 95925677ca47beb0b8cce7c0e0011bcc3f61470f */ id = strchr(pos, ' ');