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>
---
Version 2 of the log.date patch. Changes to the first version:
* use log.date instead of format.date
* Do not add the missing rev-list option as it does not logically belong
to the same commit
Documentation/config.txt | 6 ++++++
Documentation/rev-list-options.txt | 3 ++-
builtin-log.c | 10 ++++++++++
3 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 217980f..e9d9b95 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -815,6 +815,12 @@ instaweb.port::
The port number to bind the gitweb httpd to. See
linkgit:git-instaweb[1].
+log.date::
+ Set default date-time mode for the log command. Setting log.date
+ value is similar to using git log's --date option. The value is one of
+ following alternatives: {relative,local,default,iso,rfc,short}.
+ See linkgit:git-log[1].
+
log.showroot::
If true, the initial commit will be shown as a big creation event.
This is equivalent to a diff against an empty tree.
diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt
index ce6a101..631e9f4 100644
--- a/Documentation/rev-list-options.txt
+++ b/Documentation/rev-list-options.txt
@@ -16,7 +16,8 @@ include::pretty-options.txt[]
--date={relative,local,default,iso,rfc}::
Only takes effect for dates shown in human-readable format, such
- as when using "--pretty".
+ as when using "--pretty". log.date config variable sets a default
+ value for log command's --date option.
+
`--date=relative` shows dates relative to the current time,
e.g. "2 hours ago".
diff --git a/builtin-log.c b/builtin-log.c
index 9d046b2..543855b 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -18,6 +18,9 @@
#include "run-command.h"
#include "shortlog.h"
+/* Set a default date-time format for git log ("log.date" config variable) */
+static const char *default_date_mode = NULL;
+
static int default_show_root = 1;
static const char *fmt_patch_subject_prefix = "PATCH";
static const char *fmt_pretty;
@@ -61,7 +64,12 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
DIFF_OPT_SET(&rev->diffopt, RECURSIVE);
rev->show_root_diff = default_show_root;
rev->subject_prefix = fmt_patch_subject_prefix;
+
+ if (default_date_mode)
+ rev->date_mode = parse_date_format(default_date_mode);
+
argc = setup_revisions(argc, argv, rev, "HEAD");
+
if (rev->diffopt.pickaxe || rev->diffopt.filter)
rev->always_show_header = 0;
if (DIFF_OPT_TST(&rev->diffopt, FOLLOW_RENAMES)) {
@@ -232,6 +240,8 @@ static int git_log_config(const char *var, const char *value)
fmt_patch_subject_prefix = xstrdup(value);
return 0;
}
+ if (!strcmp(var, "log.date"))
+ return git_config_string(&default_date_mode, var, value);
if (!strcmp(var, "log.showroot")) {
default_show_root = git_config_bool(var, value);
return 0;
--
1.5.4.1
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
| Eric Paris | TALPA - a threat model? well sorta. |
| Vladislav Bolkhovitin | Re: Integration of SCST in the mainstream Linux kernel |
| Andrew Morton | Re: [BUILD-FAILURE] 2.6.26-rc8-mm1 - x86 - __ptep_modify_prot_start() missing |
| Bodo Eggert | Re: [PATCH] x86: provide a DMI based port 0x80 I/O delay override. |
git: | |
| Pavel Roskin | Implementing branch attributes in git config |
| Jon Smirl | Importing Mozilla CVS into git |
| Jon Smirl | Figured out how to get Mozilla into git |
| Jakub Narebski | Re: VCS comparison table |
| Richard Stallman | Real men don't attack straw men |
| Adam Getchell | Re: About Xen: maybe a reiterative question but .. |
| carlopmart | About Xen: maybe a reiterative question but .. |
| Bertram Scharpf | First install: Grub doesn't find partitions |
| Waskiewicz Jr, Peter P | RE: [PATCH 2/3][NET_BATCH] net core use batching |
| Jeff Kirsher | [PATCH 1/3] e1000e: add support for the 82567LM-4 device |
| Ayaz Abdulla | [PATCH] forcedeth: msi interrupts |
| Corey Hickey | [PATCH 10/10] Use nested compat attributes to pass parameters. |
