{"thread":{"id":"13614","subject":"[PATCH] Add log.date config variable","startedAt":"2008-05-22T15:24:07Z","lastAt":"2008-05-22T15:24:07Z","messageCount":1,"participants":["Heikki Orsila"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"77474","messageId":"20080522152406.GA20556@zakalwe.fi","threadId":"13614","inReplyTo":null,"subject":"[PATCH] Add log.date config variable","fromName":"Heikki Orsila","fromEmail":"heikki.orsila@iki.fi","sentAt":"2008-05-22T15:24:07Z","receivedAt":"2008-05-22T15:24:07Z","isPatch":true,"sender":{"key":"heikki.orsila@iki.fi","avatar":null},"body":"log.date config variable sets the default date-time mode for the log\ncommand. Setting log.date value is similar to using git log's --date\noption.\n\nSigned-off-by: Heikki Orsila <heikki.orsila@iki.fi>\n---\nVersion 2 of the log.date patch. Changes to the first version:\n\n* use log.date instead of format.date\n\n* Do not add the missing rev-list option as it does not logically belong\n  to the same commit\n\n Documentation/config.txt           |    6 ++++++\n Documentation/rev-list-options.txt |    3 ++-\n builtin-log.c                      |   10 ++++++++++\n 3 files changed, 18 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 217980f..e9d9b95 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -815,6 +815,12 @@ instaweb.port::\n \tThe port number to bind the gitweb httpd to. See\n \tlinkgit:git-instaweb[1].\n \n+log.date::\n+\tSet default date-time mode for the log command. Setting log.date\n+\tvalue is similar to using git log's --date option. The value is one of\n+\tfollowing alternatives: {relative,local,default,iso,rfc,short}.\n+\tSee linkgit:git-log[1].\n+\n log.showroot::\n \tIf true, the initial commit will be shown as a big creation event.\n \tThis is equivalent to a diff against an empty tree.\ndiff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt\nindex ce6a101..631e9f4 100644\n--- a/Documentation/rev-list-options.txt\n+++ b/Documentation/rev-list-options.txt\n@@ -16,7 +16,8 @@ include::pretty-options.txt[]\n --date={relative,local,default,iso,rfc}::\n \n \tOnly takes effect for dates shown in human-readable format, such\n-\tas when using \"--pretty\".\n+\tas when using \"--pretty\". log.date config variable sets a default\n+\tvalue for log command's --date option.\n +\n `--date=relative` shows dates relative to the current time,\n e.g. \"2 hours ago\".\ndiff --git a/builtin-log.c b/builtin-log.c\nindex 9d046b2..543855b 100644\n--- a/builtin-log.c\n+++ b/builtin-log.c\n@@ -18,6 +18,9 @@\n #include \"run-command.h\"\n #include \"shortlog.h\"\n \n+/* Set a default date-time format for git log (\"log.date\" config variable) */\n+static const char *default_date_mode = NULL;\n+\n static int default_show_root = 1;\n static const char *fmt_patch_subject_prefix = \"PATCH\";\n static const char *fmt_pretty;\n@@ -61,7 +64,12 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,\n \tDIFF_OPT_SET(&rev->diffopt, RECURSIVE);\n \trev->show_root_diff = default_show_root;\n \trev->subject_prefix = fmt_patch_subject_prefix;\n+\n+\tif (default_date_mode)\n+\t\trev->date_mode = parse_date_format(default_date_mode);\n+\n \targc = setup_revisions(argc, argv, rev, \"HEAD\");\n+\n \tif (rev->diffopt.pickaxe || rev->diffopt.filter)\n \t\trev->always_show_header = 0;\n \tif (DIFF_OPT_TST(&rev->diffopt, FOLLOW_RENAMES)) {\n@@ -232,6 +240,8 @@ static int git_log_config(const char *var, const char *value)\n \t\tfmt_patch_subject_prefix = xstrdup(value);\n \t\treturn 0;\n \t}\n+\tif (!strcmp(var, \"log.date\"))\n+\t\treturn git_config_string(&default_date_mode, var, value);\n \tif (!strcmp(var, \"log.showroot\")) {\n \t\tdefault_show_root = git_config_bool(var, value);\n \t\treturn 0;\n-- \n1.5.4.1\n"}]}