Skip to content

Commit 7351f17

Browse files
committed
Show committer date by default in the date column
Although the author name is generally of more interest than the committer name, the committer date is more significant as it shows when the change was actually added to the commit history. Make it the default for the date column. The author date can be restored on a per-view basis using the `use-author` option of the `date` column in the view settings of ~/.tigrc. See tigrc(5). Note: to have both author date and committer date shown in the log view, add `--pretty=fuller` to `log-options`. Closes #294
1 parent 921c001 commit 7351f17

26 files changed

+102
-58
lines changed

NEWS.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Improvements:
1717
- Make errors visible in views showing Git output. (#1346)
1818
- Allow different colors for all references types.
1919
- Enable search in sections titles. (#1043)
20+
- Show committer date by default in the date column. (#294)
2021

2122
tig-2.5.10
2223
----------

doc/manual.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ from an external command, most often 'git log', 'git diff', or 'git show'.
8888

8989
The main view::
9090
Is the default view, and it shows a one line summary of each commit
91-
in the chosen list of revisions. The summary includes author date,
92-
author, and the first line of the log message. Additionally, any
93-
repository references, such as tags, will be shown.
91+
in the chosen list of revisions. The summary includes committer date
92+
or author date, author, and the first line of the log message.
93+
Additionally, any repository references, such as tags, will be shown.
9494

9595
The log view::
9696
Presents a more rich view of the revision log showing the whole log

doc/tigrc.5.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,8 @@ date::
509509
relative date will be used, e.g. "2 minutes ago" or "2m". If set to
510510
"custom", the strftime(3) string format specified in the "format"
511511
option is used.
512+
- 'use-author' (bool): Whether to show author date instead of committer
513+
date.
512514
- 'local' (bool): If true, use localtime(3) to convert to local
513515
timezone. Note that relative dates always use local offsets.
514516
- 'format' (string): format string to pass to strftime(3) when 'custom'
@@ -1068,7 +1070,7 @@ setting the *default* color option.
10681070
sections in the help view.
10691071
|line-number |Line numbers.
10701072
|id |The commit ID.
1071-
|date |The author date.
1073+
|date |The committer date or author date.
10721074
|author |The commit author.
10731075
|mode |The file mode holding the permissions and type.
10741076
|overflow |Title text overflow.

include/tig/options.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ OPTION_INFO(DEFINE_OPTION_EXTERNS)
110110

111111
#define DATE_COLUMN_OPTIONS(_) \
112112
_(display, enum date, VIEW_NO_FLAGS) \
113+
_(use_author, bool, VIEW_NO_FLAGS) \
113114
_(local, bool, VIEW_NO_FLAGS) \
114115
_(format, const char *, VIEW_NO_FLAGS) \
115116
_(width, int, VIEW_NO_FLAGS) \
@@ -196,7 +197,7 @@ void update_options_from_argv(const char *argv[]);
196197
const char *ignore_space_arg();
197198
const char *commit_order_arg();
198199
const char *commit_order_arg_with_graph(enum graph_display graph_display);
199-
const char *log_custom_pretty_arg();
200+
const char *log_custom_pretty_arg(bool use_author_date);
200201
const char *use_mailmap_arg();
201202
const char *diff_context_arg();
202203
const char *diff_prefix_arg();

include/tig/parse.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ struct blame_header {
4848
};
4949

5050
bool parse_blame_header(struct blame_header *header, const char *text);
51-
bool parse_blame_info(struct blame_commit *commit, char author[SIZEOF_STR], char *line);
51+
bool parse_blame_info(struct blame_commit *commit, char author[SIZEOF_STR], char *line, bool use_author_date);
5252

5353
/* Parse author lines where the name may be empty:
5454
* author <[email protected]> 1138474660 +0100

src/blame.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,8 @@ static bool
219219
blame_read(struct view *view, struct buffer *buf, bool force_stop)
220220
{
221221
struct blame_state *state = view->private;
222+
struct view_column *column = get_view_column(view, VIEW_COLUMN_DATE);
223+
bool use_author_date = column && column->opt.date.use_author;
222224

223225
if (!buf) {
224226
if (failed_to_load_initial_view(view))
@@ -256,7 +258,7 @@ blame_read(struct view *view, struct buffer *buf, bool force_stop)
256258

257259
state->commit = NULL;
258260

259-
} else if (parse_blame_info(state->commit, state->author, buf->data)) {
261+
} else if (parse_blame_info(state->commit, state->author, buf->data, use_author_date)) {
260262
if (!state->commit->filename)
261263
return false;
262264

src/diff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ diff_blame_line(const char *ref, const char *file, unsigned long lineno,
588588
break;
589589
header = NULL;
590590

591-
} else if (parse_blame_info(commit, author, buf.data)) {
591+
} else if (parse_blame_info(commit, author, buf.data, false)) {
592592
ok = commit->filename != NULL;
593593
break;
594594
}

src/main.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,12 @@ main_open(struct view *view, enum open_flags flags)
276276
{
277277
struct view_column *commit_title_column = get_view_column(view, VIEW_COLUMN_COMMIT_TITLE);
278278
enum graph_display graph_display = main_with_graph(view, commit_title_column, flags);
279+
struct view_column *column = get_view_column(view, VIEW_COLUMN_DATE);
280+
bool use_author_date = column && column->opt.date.use_author;
279281
const char *pretty_custom_argv[] = {
280282
GIT_MAIN_LOG(encoding_arg, commit_order_arg_with_graph(graph_display),
281283
"%(mainargs)", "%(cmdlineargs)", "%(revargs)", "%(fileargs)",
282-
show_notes_arg(), log_custom_pretty_arg())
284+
show_notes_arg(), log_custom_pretty_arg(use_author_date))
283285
};
284286
const char *pretty_raw_argv[] = {
285287
GIT_MAIN_LOG_RAW(encoding_arg, commit_order_arg_with_graph(graph_display),

src/options.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,15 @@ use_mailmap_arg()
159159
}
160160

161161
const char *
162-
log_custom_pretty_arg(void)
162+
log_custom_pretty_arg(bool use_author_date)
163163
{
164-
return opt_mailmap
165-
? "--pretty=format:commit %m %H %P%x00%aN <%aE> %ad%x00%s%x00%N"
166-
: "--pretty=format:commit %m %H %P%x00%an <%ae> %ad%x00%s%x00%N";
164+
return use_author_date
165+
? opt_mailmap
166+
? "--pretty=format:commit %m %H %P%x00%aN <%aE> %ad%x00%s%x00%N"
167+
: "--pretty=format:commit %m %H %P%x00%an <%ae> %ad%x00%s%x00%N"
168+
: opt_mailmap
169+
? "--pretty=format:commit %m %H %P%x00%aN <%aE> %cd%x00%s%x00%N"
170+
: "--pretty=format:commit %m %H %P%x00%an <%ae> %cd%x00%s%x00%N";
167171
}
168172

169173
#define ENUM_ARG(enum_name, arg_string) ENUM_MAP_ENTRY(arg_string, enum_name)

src/parse.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ parse_author_line(char *ident, const struct ident **author, struct time *time)
7373
if (!*email)
7474
email = *name ? name : unknown_ident.email;
7575

76-
*author = get_author(name, email);
76+
if (author)
77+
*author = get_author(name, email);
7778

7879
/* Parse epoch and timezone */
7980
if (time && emailend && emailend[1] == ' ') {
@@ -138,7 +139,7 @@ match_blame_header(const char *name, char **line)
138139
}
139140

140141
bool
141-
parse_blame_info(struct blame_commit *commit, char author[SIZEOF_STR], char *line)
142+
parse_blame_info(struct blame_commit *commit, char author[SIZEOF_STR], char *line, bool use_author_date)
142143
{
143144
if (match_blame_header("author ", &line)) {
144145
string_ncopy_do(author, SIZEOF_STR, line, strlen(line));
@@ -153,10 +154,10 @@ parse_blame_info(struct blame_commit *commit, char author[SIZEOF_STR], char *lin
153154
commit->author = get_author(author, line);
154155
author[0] = 0;
155156

156-
} else if (match_blame_header("author-time ", &line)) {
157+
} else if (match_blame_header(use_author_date ? "author-time " : "committer-time ", &line)) {
157158
parse_timesec(&commit->time, line);
158159

159-
} else if (match_blame_header("author-tz ", &line)) {
160+
} else if (match_blame_header(use_author_date ? "author-tz " : "committer-tz ", &line)) {
160161
parse_timezone(&commit->time, line);
161162

162163
} else if (match_blame_header("summary ", &line)) {

0 commit comments

Comments
 (0)