Skip to content

Commit dd0ffd5

Browse files
heikkiorsilagitster
authored andcommitted
Add log.date config variable
log.date config variable sets the default date-time mode for the log command. Setting log.date value is similar to using git log's --date option. Signed-off-by: Heikki Orsila <heikki.orsila@iki.fi> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 950ce2e commit dd0ffd5

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

Documentation/config.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,12 @@ instaweb.port::
817817
The port number to bind the gitweb httpd to. See
818818
linkgit:git-instaweb[1].
819819

820+
log.date::
821+
Set default date-time mode for the log command. Setting log.date
822+
value is similar to using git log's --date option. The value is one of
823+
following alternatives: {relative,local,default,iso,rfc,short}.
824+
See linkgit:git-log[1].
825+
820826
log.showroot::
821827
If true, the initial commit will be shown as a big creation event.
822828
This is equivalent to a diff against an empty tree.

Documentation/rev-list-options.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ include::pretty-options.txt[]
1616
--date={relative,local,default,iso,rfc}::
1717

1818
Only takes effect for dates shown in human-readable format, such
19-
as when using "--pretty".
19+
as when using "--pretty". `log.date` config variable sets a default
20+
value for log command's --date option.
2021
+
2122
`--date=relative` shows dates relative to the current time,
2223
e.g. "2 hours ago".

builtin-log.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
#include "run-command.h"
1919
#include "shortlog.h"
2020

21+
/* Set a default date-time format for git log ("log.date" config variable) */
22+
static const char *default_date_mode = NULL;
23+
2124
static int default_show_root = 1;
2225
static const char *fmt_patch_subject_prefix = "PATCH";
2326
static const char *fmt_pretty;
@@ -61,7 +64,12 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
6164
DIFF_OPT_SET(&rev->diffopt, RECURSIVE);
6265
rev->show_root_diff = default_show_root;
6366
rev->subject_prefix = fmt_patch_subject_prefix;
67+
68+
if (default_date_mode)
69+
rev->date_mode = parse_date_format(default_date_mode);
70+
6471
argc = setup_revisions(argc, argv, rev, "HEAD");
72+
6573
if (rev->diffopt.pickaxe || rev->diffopt.filter)
6674
rev->always_show_header = 0;
6775
if (DIFF_OPT_TST(&rev->diffopt, FOLLOW_RENAMES)) {
@@ -232,6 +240,8 @@ static int git_log_config(const char *var, const char *value)
232240
fmt_patch_subject_prefix = xstrdup(value);
233241
return 0;
234242
}
243+
if (!strcmp(var, "log.date"))
244+
return git_config_string(&default_date_mode, var, value);
235245
if (!strcmp(var, "log.showroot")) {
236246
default_show_root = git_config_bool(var, value);
237247
return 0;

0 commit comments

Comments
 (0)