@matheusbsbs / matheus-bagliano / commits / dd0ffd5b31
Fork 0

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>

Heikki Orsila committed May 22, 2008 at 18:24 UTC dd0ffd5b31a672db90d8b775988d55829e6f5f9f
3 files changed +18 -1
Documentation/config.txt
+6
@@ -817,6 +817,12 @@ instaweb.port::
817 The port number to bind the gitweb httpd to. See
818 linkgit:git-instaweb[1].
819
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 +
826 log.showroot::
827 If true, the initial commit will be shown as a big creation event.
828 This is equivalent to a diff against an empty tree.
Documentation/rev-list-options.txt
+2 -1
@@ -16,7 +16,8 @@ include::pretty-options.txt[]
16 --date={relative,local,default,iso,rfc}::
17
18 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.
21 +
22 `--date=relative` shows dates relative to the current time,
23 e.g. "2 hours ago".
builtin-log.c
+10
@@ -18,6 +18,9 @@
18 #include "run-command.h"
19 #include "shortlog.h"
20
21 +/* Set a default date-time format for git log ("log.date" config variable) */
22 +static const char *default_date_mode = NULL;
23 +
24 static int default_show_root = 1;
25 static const char *fmt_patch_subject_prefix = "PATCH";
26 static const char *fmt_pretty;
@@ -61,7 +64,12 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
64 DIFF_OPT_SET(&rev->diffopt, RECURSIVE);
65 rev->show_root_diff = default_show_root;
66 rev->subject_prefix = fmt_patch_subject_prefix;
67 +
68 + if (default_date_mode)
69 + rev->date_mode = parse_date_format(default_date_mode);
70 +
71 argc = setup_revisions(argc, argv, rev, "HEAD");
72 +
73 if (rev->diffopt.pickaxe || rev->diffopt.filter)
74 rev->always_show_header = 0;
75 if (DIFF_OPT_TST(&rev->diffopt, FOLLOW_RENAMES)) {
@@ -232,6 +240,8 @@ static int git_log_config(const char *var, const char *value)
240 fmt_patch_subject_prefix = xstrdup(value);
241 return 0;
242 }
243 + if (!strcmp(var, "log.date"))
244 + return git_config_string(&default_date_mode, var, value);
245 if (!strcmp(var, "log.showroot")) {
246 default_show_root = git_config_bool(var, value);
247 return 0;