git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Add format.date config variable
@ 2008-05-18 17:13 Heikki Orsila
  2008-05-18 17:39 ` Teemu Likonen
  2008-05-21 18:24 ` Junio C Hamano
  0 siblings, 2 replies; 4+ messages in thread
From: Heikki Orsila @ 2008-05-18 17:13 UTC (permalink / raw)
  To: git

format.date config variable sets the default date-time mode for the log
command. Setting format.date value is similar to using git log's --date
option.

Also, add missing "short" alternative to --date in rev-list-options.txt.
---
I wanted to read all the logs in ISO 8601 time format so I decided to 
implement this option.

 Documentation/config.txt           |    6 ++++++
 Documentation/rev-list-options.txt |    5 +++--
 builtin-log.c                      |   10 ++++++++++
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 217980f..ddc68bd 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -573,6 +573,12 @@ fetch.unpackLimit::
 	especially on slow filesystems.  If not set, the value of
 	`transfer.unpackLimit` is used instead.
 
+format.date::
+	Set default date-time mode for the log command. Setting format.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].
+
 format.numbered::
 	A boolean which can enable sequence numbers in patch subjects.
 	Setting this option to "auto" will enable it only if there is
diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt
index 2648a55..3d47dc9 100644
--- a/Documentation/rev-list-options.txt
+++ b/Documentation/rev-list-options.txt
@@ -13,10 +13,11 @@ include::pretty-options.txt[]
 
 	Synonym for `--date=relative`.
 
---date={relative,local,default,iso,rfc}::
+--date={relative,local,default,iso,rfc,short}::
 
 	Only takes effect for dates shown in human-readable format, such
-	as when using "--pretty".
+	as when using "--pretty". format.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..d3ff8f6 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 */
+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)) {
@@ -224,6 +232,8 @@ static int cmd_log_walk(struct rev_info *rev)
 
 static int git_log_config(const char *var, const char *value)
 {
+	if (!strcmp(var, "format.date"))
+		return git_config_string(&default_date_mode, var, value);
 	if (!strcmp(var, "format.pretty"))
 		return git_config_string(&fmt_pretty, var, value);
 	if (!strcmp(var, "format.subjectprefix")) {
-- 
1.5.4.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Add format.date config variable
  2008-05-18 17:13 [PATCH] Add format.date config variable Heikki Orsila
@ 2008-05-18 17:39 ` Teemu Likonen
  2008-05-21 18:24 ` Junio C Hamano
  1 sibling, 0 replies; 4+ messages in thread
From: Teemu Likonen @ 2008-05-18 17:39 UTC (permalink / raw)
  To: Heikki Orsila; +Cc: git

Heikki Orsila kirjoitti (18.5.2008 klo 20.13):

> I wanted to read all the logs in ISO 8601 time format so I decided to
> implement this option.

Thank you. To my (our) Finnish eyes ISO 8601 is much clearer than the
default.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Add format.date config variable
  2008-05-18 17:13 [PATCH] Add format.date config variable Heikki Orsila
  2008-05-18 17:39 ` Teemu Likonen
@ 2008-05-21 18:24 ` Junio C Hamano
  2008-05-21 23:27   ` Heikki Orsila
  1 sibling, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2008-05-21 18:24 UTC (permalink / raw)
  To: Heikki Orsila; +Cc: git

Heikki Orsila <heikki.orsila@iki.fi> writes:

> format.date config variable sets the default date-time mode for the log
> command. Setting format.date value is similar to using git log's --date
> option.
>
> Also, add missing "short" alternative to --date in rev-list-options.txt.

Good change but is a separate issue.  Please make it a [PATCH 1/2].

> ---

Lacking Sign-off.

> I wanted to read all the logs in ISO 8601 time format so I decided to 
> implement this option.

Good intention.

> diff --git a/Documentation/config.txt b/Documentation/config.txt
> index 217980f..ddc68bd 100644
> --- a/Documentation/config.txt
> +++ b/Documentation/config.txt
> @@ -573,6 +573,12 @@ fetch.unpackLimit::
>  	especially on slow filesystems.  If not set, the value of
>  	`transfer.unpackLimit` is used instead.
>  
> +format.date::
> +	Set default date-time mode for the log command. Setting format.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].
> +

Look at other "format.*" variables --- notice that most of them are about
"format-patch" command?  And you absolutely do NOT want this "default date
format for log family" to apply to "format-patch" command.

> diff --git a/builtin-log.c b/builtin-log.c
> index 9d046b2..d3ff8f6 100644
> --- a/builtin-log.c
> +++ b/builtin-log.c
> @@ -18,6 +18,9 @@

The patch itself is good, especially that you made sure that format-patch
output is not affected.

As to the configuration variable name, I'd suggest "log.date" instead.  We
may have to deprecate format.pretty and move it to something else for
consistency, though.  Just like we do not want "format.date" applied to
format-patch, we never want "format.pretty" apply to it either.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Add format.date config variable
  2008-05-21 18:24 ` Junio C Hamano
@ 2008-05-21 23:27   ` Heikki Orsila
  0 siblings, 0 replies; 4+ messages in thread
From: Heikki Orsila @ 2008-05-21 23:27 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Wed, May 21, 2008 at 11:24:42AM -0700, Junio C Hamano wrote:
> > Also, add missing "short" alternative to --date in rev-list-options.txt.
> 
> Good change but is a separate issue.  Please make it a [PATCH 1/2].

Will do that a separate patch.

> Lacking Sign-off.

OK. Thanks.

> The patch itself is good, especially that you made sure that format-patch
> output is not affected.
> 
> As to the configuration variable name, I'd suggest "log.date" instead.

OK.

Will submit a patch later today.

-- 
Heikki Orsila
heikki.orsila@iki.fi
http://www.iki.fi/shd

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-05-21 23:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-18 17:13 [PATCH] Add format.date config variable Heikki Orsila
2008-05-18 17:39 ` Teemu Likonen
2008-05-21 18:24 ` Junio C Hamano
2008-05-21 23:27   ` Heikki Orsila

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).