threads / patch / 59176

patchrev-list: clarify git-log default date format

Subject: [PATCH] rev-list: clarify git-log default date format

## tl;dr

13 messages between Feb 1, 2023 and Feb 16, 2023. Diffs are folded; open one to read it.

replies: 12people: 4as markdown or json

Rafael Dulfer· Feb 1, 2023, 15:57 UTC · lore
From: Rafael Dulfer <rafael.dulfer@gmail.com>
Currently, the documentation is slightly incomplete, not explaining all the differences the default format has with rfc2822. Leading to confusion for people trying to parse the date format outputted by git log
This patch adds 2 more exceptions when compared to rfc2822. Also adds an example of what the format looks like (I originally wanted to specify this in strftime notation, but because of the way day-of-month is formatted this is impossible)
Signed-off-by: Rafael Dulfer <rafael.dulfer@gmail.com>
---
 Documentation/rev-list-options.txt | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
Show changes to Documentation/rev-list-options.txt +8 −2
diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt
index ff68e48406..8bc8475f3e 100644
--- a/Documentation/rev-list-options.txt
+++ b/Documentation/rev-list-options.txt
@@ -1103,9 +1103,15 @@ format placeholders. When using `-local`, the correct syntax is
 `--date=default` is the default format, and is similar to
 `--date=rfc2822`, with a few exceptions:
 --
-	- there is no comma after the day-of-week
+	- There is no comma after the day-of-week
 
-	- the time zone is omitted when the local time zone is used
+	- The time zone is omitted when the local time zone is used
+
+	- Day-of-month and month are switched around
+
+	- Time-of-day and the year are switched around
+
+As a result, the format looks as follows: `Thu Jan 1 00:00:00 1970 +0000` with `+0000` being omitted when the local time zone is used.
 
 ifdef::git-rev-list[]
 --header::
-- 
2.39.1
Junio C Hamano· Feb 1, 2023, 18:19 UTC · re: Rafael Dulfer · lore

Re: [PATCH] rev-list: clarify git-log default date format

Rafael Dulfer <rafael@dulfer.be> writes:
Show 5 quoted lines
> From: Rafael Dulfer <rafael.dulfer@gmail.com>
>
> Currently, the documentation is slightly incomplete, not explaining all the differences the default format has with rfc2822. Leading to confusion for people trying to parse the date format outputted by git log
>
> This patch adds 2 more exceptions when compared to rfc2822. Also adds an example of what the format looks like (I originally wanted to specify this in strftime notation, but because of the way day-of-month is formatted this is impossible)
Overly long lines.
Show 25 quoted lines
>
> Signed-off-by: Rafael Dulfer <rafael.dulfer@gmail.com>
> ---
>  Documentation/rev-list-options.txt | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt
> index ff68e48406..8bc8475f3e 100644
> --- a/Documentation/rev-list-options.txt
> +++ b/Documentation/rev-list-options.txt
> @@ -1103,9 +1103,15 @@ format placeholders. When using `-local`, the correct syntax is
>  `--date=default` is the default format, and is similar to
>  `--date=rfc2822`, with a few exceptions:
>  --
> -	- there is no comma after the day-of-week
> +	- There is no comma after the day-of-week
>  
> -	- the time zone is omitted when the local time zone is used
> +	- The time zone is omitted when the local time zone is used
> +
> +	- Day-of-month and month are switched around
> +
> +	- Time-of-day and the year are switched around
> +
> +As a result, the format looks as follows: `Thu Jan 1 00:00:00 1970 +0000` with `+0000` being omitted when the local time zone is used.

All of the above may technically be correct, but I wonder if it makes it easier to follow to simply stop saying "is similar to". That is

    The default format `--date=default` shows a single line with
    three-letter day of the week, three-letter month, day-of-month,
    hour-minute-second in the "HH:MM:SS" format, followed by 4-digit
    year, plus timezone information unless the local time zone is
    used (e.g. "Thu Jan 1 00:00:00 1970 +0000").
or something like that.
Jeff King· Feb 1, 2023, 22:47 UTC · re: Junio C Hamano · lore

Re: [PATCH] rev-list: clarify git-log default date format

On Wed, Feb 01, 2023 at 10:19:02AM -0800, Junio C Hamano wrote:
Show 23 quoted lines
> > -	- there is no comma after the day-of-week
> > +	- There is no comma after the day-of-week
> >  
> > -	- the time zone is omitted when the local time zone is used
> > +	- The time zone is omitted when the local time zone is used
> > +
> > +	- Day-of-month and month are switched around
> > +
> > +	- Time-of-day and the year are switched around
> > +
> > +As a result, the format looks as follows: `Thu Jan 1 00:00:00 1970 +0000` with `+0000` being omitted when the local time zone is used.
> 
> All of the above may technically be correct, but I wonder if it
> makes it easier to follow to simply stop saying "is similar to".
> That is
> 
>     The default format `--date=default` shows a single line with
>     three-letter day of the week, three-letter month, day-of-month,
>     hour-minute-second in the "HH:MM:SS" format, followed by 4-digit
>     year, plus timezone information unless the local time zone is
>     used (e.g. "Thu Jan 1 00:00:00 1970 +0000").
> 
> or something like that.

Yes, I agree with your suggestion. When you can explain something as "like X, but Y" it is helpful when Y is short. When it becomes much longer, than simply spelling out what X is becomes more helpful.

-Peff
Ævar Arnfjörð Bjarmason· Feb 1, 2023, 22:28 UTC · re: Junio C Hamano · lore

Re: [PATCH] rev-list: clarify git-log default date format

On Wed, Feb 01 2023, Junio C Hamano wrote:
Show 53 quoted lines
> Rafael Dulfer <rafael@dulfer.be> writes:
>
>> From: Rafael Dulfer <rafael.dulfer@gmail.com>
>>
>> Currently, the documentation is slightly incomplete, not explaining
>> all the differences the default format has with rfc2822. Leading to
>> confusion for people trying to parse the date format outputted by
>> git log
>>
>> This patch adds 2 more exceptions when compared to rfc2822. Also
>> adds an example of what the format looks like (I originally wanted
>> to specify this in strftime notation, but because of the way
>> day-of-month is formatted this is impossible)
>
> Overly long lines.
>
>>
>> Signed-off-by: Rafael Dulfer <rafael.dulfer@gmail.com>
>> ---
>>  Documentation/rev-list-options.txt | 10 ++++++++--
>>  1 file changed, 8 insertions(+), 2 deletions(-)
>>
>> diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt
>> index ff68e48406..8bc8475f3e 100644
>> --- a/Documentation/rev-list-options.txt
>> +++ b/Documentation/rev-list-options.txt
>> @@ -1103,9 +1103,15 @@ format placeholders. When using `-local`, the correct syntax is
>>  `--date=default` is the default format, and is similar to
>>  `--date=rfc2822`, with a few exceptions:
>>  --
>> -	- there is no comma after the day-of-week
>> +	- There is no comma after the day-of-week
>>  
>> -	- the time zone is omitted when the local time zone is used
>> +	- The time zone is omitted when the local time zone is used
>> +
>> +	- Day-of-month and month are switched around
>> +
>> +	- Time-of-day and the year are switched around
>> +
>> +As a result, the format looks as follows: `Thu Jan 1 00:00:00 1970 +0000` with `+0000` being omitted when the local time zone is used.
>
> All of the above may technically be correct, but I wonder if it
> makes it easier to follow to simply stop saying "is similar to".
> That is
>
>     The default format `--date=default` shows a single line with
>     three-letter day of the week, three-letter month, day-of-month,
>     hour-minute-second in the "HH:MM:SS" format, followed by 4-digit
>     year, plus timezone information unless the local time zone is
>     used (e.g. "Thu Jan 1 00:00:00 1970 +0000").
>
> or something like that.
I think that following such a description in prose is still more
confusing than just showing an example. E.g. we could say:
	
	Assuming a user in timezone +0200 (Central Europe) values of
	these `--date` argument would produce:
	
	|---------------+--------------------------------|
	| rfc2822       | Thu, 7 Apr 2005 15:13:13 -0700 |
	| rfc2822-local | Fri, 8 Apr 2005 00:13:13 +0200 |
	| default       | Thu Apr 7 15:13:13 2005 -0700  |
	| default-local | Fri Apr 8 00:13:13 2005        |
	|---------------+--------------------------------|
	
In particular your example says "unless the local time zone is used",
but then shows an example that's 'default', not 'default-local'.
Junio C Hamano· Feb 1, 2023, 22:58 UTC · re: Ævar Arnfjörð Bjarmason · lore

Re: [PATCH] rev-list: clarify git-log default date format

Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
Show 14 quoted lines
>> That is
>>
>>     The default format `--date=default` shows a single line with
>>     three-letter day of the week, three-letter month, day-of-month,
>>     hour-minute-second in the "HH:MM:SS" format, followed by 4-digit
>>     year, plus timezone information unless the local time zone is
>>     used (e.g. "Thu Jan 1 00:00:00 1970 +0000").
>>
>> or something like that.
>
> I think that following such a description in prose is still more
> confusing than just showing an example. E.g. we could say:
> 	
> 	Assuming a user in timezone +0200 (Central Europe) values of
Add "on day X at time Y" here, and I'd buy that ;-)
Show 8 quoted lines
> 	these `--date` argument would produce:
> 	
> 	|---------------+--------------------------------|
> 	| rfc2822       | Thu, 7 Apr 2005 15:13:13 -0700 |
> 	| rfc2822-local | Fri, 8 Apr 2005 00:13:13 +0200 |
> 	| default       | Thu Apr 7 15:13:13 2005 -0700  |
> 	| default-local | Fri Apr 8 00:13:13 2005        |
> 	|---------------+--------------------------------|
Rafael Dulfer· Feb 2, 2023, 11:37 UTC · re: Junio C Hamano · lore

Re: [PATCH] rev-list: clarify git-log default date format

> Add "on day X at time Y" here, and I'd buy that 😉

Feels to me that adding "on day X at time Y" is a bit superfluous, since it's quite obvious from the examples, but I guess it can't hurt to be exact.

I think it would be a good idea to still have _some_ text for `--date=default`, just so the structure of the sections stays the same over all the date options. Maybe just something simple like. "`--date=default` is the default format. It is a custom format based on rfc2822". And then below that we have the table (which is more a conclusion to the section, as it provides examples for a few, more unclear, formats)

On 01/02/2023 23:58, Junio C Hamano wrote:
Show 25 quoted lines
> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>
>>> That is
>>>
>>>      The default format `--date=default` shows a single line with
>>>      three-letter day of the week, three-letter month, day-of-month,
>>>      hour-minute-second in the "HH:MM:SS" format, followed by 4-digit
>>>      year, plus timezone information unless the local time zone is
>>>      used (e.g. "Thu Jan 1 00:00:00 1970 +0000").
>>>
>>> or something like that.
>> I think that following such a description in prose is still more
>> confusing than just showing an example. E.g. we could say:
>> 	
>> 	Assuming a user in timezone +0200 (Central Europe) values of
> Add "on day X at time Y" here, and I'd buy that ;-)
>
>> 	these `--date` argument would produce:
>> 	
>> 	|---------------+--------------------------------|
>> 	| rfc2822       | Thu, 7 Apr 2005 15:13:13 -0700 |
>> 	| rfc2822-local | Fri, 8 Apr 2005 00:13:13 +0200 |
>> 	| default       | Thu Apr 7 15:13:13 2005 -0700  |
>> 	| default-local | Fri Apr 8 00:13:13 2005        |
>> 	|---------------+--------------------------------|
Junio C Hamano· Feb 2, 2023, 16:17 UTC · re: Rafael Dulfer · lore

Re: [PATCH] rev-list: clarify git-log default date format

Rafael Dulfer <rafael@dulfer.be> writes:
> like. "`--date=default` is the default format. It is a custom format
> based on rfc2822".

But the thing is it is *not* custom based on rfc2822. The default format came first, 2822 much later. If I have to guess (and I shouldn't because I was around back when we invented that format, but I am lazy and my recollecion hazy), it came straight from the result of ctime() but with timezone info appended at the end.

Junio C Hamano· Feb 2, 2023, 16:53 UTC · re: Junio C Hamano · lore

Re: [PATCH] rev-list: clarify git-log default date format

Junio C Hamano <gitster@pobox.com> writes:
Show 10 quoted lines
> Rafael Dulfer <rafael@dulfer.be> writes:
>
>> like. "`--date=default` is the default format. It is a custom format
>> based on rfc2822".
>
> But the thing is it is *not* custom based on rfc2822.  The default
> format came first, 2822 much later.  If I have to guess (and I
> shouldn't because I was around back when we invented that format,
> but I am lazy and my recollecion hazy), it came straight from the
> result of ctime() but with timezone info appended at the end.

It indeed was modeled after ctime() in f80cd783 (date.c: add "show_date()" function., 2005-05-06).

    date.c: add "show_date()" function.
    
    Kind of like ctime(), but not as broken.
Junio C Hamano· Feb 16, 2023, 00:42 UTC · re: Junio C Hamano · lore

[PATCH v2] rev-list: clarify git-log default date format

The documentation mistakenly said that the default format was similar to RFC 2822 format and tried to specify it by enumerating differences, which had two problems:

 * There are some more differences from the 2822 format that are not
   mentioned; worse yet
 * The default format is not modeled after RFC 2822 format at all.
   As can be seen in f80cd783 (date.c: add "show_date()" function.,
   2005-05-06), it is a derivative of ctime(3) format.

Stop saying that it is similar to RFC 2822, and rewrite the description to explain the format without requiring the reader to know any other format.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 * The discussion stalled and the topic was left in limbo for a few
   weeks.  Let's attempt to reboot it instead of silently waiting
   for a rerolled version from the original author.
 Documentation/rev-list-options.txt | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
Show changes to Documentation/rev-list-options.txt +5 −5
diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt
index ff68e48406..9ae7ccdaa9 100644
--- a/Documentation/rev-list-options.txt
+++ b/Documentation/rev-list-options.txt
@@ -1100,12 +1100,11 @@ preferred format.  See the `strftime` manual for a complete list of
 format placeholders. When using `-local`, the correct syntax is
 `--date=format-local:...`.
 
-`--date=default` is the default format, and is similar to
-`--date=rfc2822`, with a few exceptions:
---
-	- there is no comma after the day-of-week
-
-	- the time zone is omitted when the local time zone is used
+`--date=default` is the default format, and is based on ctime(3)
+output.  It shows a single line with three-letter day of the week,
+three-letter month, day-of-month, hour-minute-seconds in "HH:MM:SS"
+format, followed by 4-digit year, plus timezone information, unless
+the local time zone is used, e.g. `Thu Jan 1 00:00:00 1970 +0000`.
 
 ifdef::git-rev-list[]
 --header::
-- 
2.39.2-456-gb1485644f9
Jeff King· Feb 16, 2023, 02:15 UTC · re: Junio C Hamano · lore

Re: [PATCH v2] rev-list: clarify git-log default date format

On Wed, Feb 15, 2023 at 04:42:25PM -0800, Junio C Hamano wrote:
Show 20 quoted lines
> The documentation mistakenly said that the default format was
> similar to RFC 2822 format and tried to specify it by enumerating
> differences, which had two problems:
> 
>  * There are some more differences from the 2822 format that are not
>    mentioned; worse yet
> 
>  * The default format is not modeled after RFC 2822 format at all.
>    As can be seen in f80cd783 (date.c: add "show_date()" function.,
>    2005-05-06), it is a derivative of ctime(3) format.
> 
> Stop saying that it is similar to RFC 2822, and rewrite the
> description to explain the format without requiring the reader to
> know any other format.
> 
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>  * The discussion stalled and the topic was left in limbo for a few
>    weeks.  Let's attempt to reboot it instead of silently waiting
>    for a rerolled version from the original author.
Thanks for keeping this moving. The proposed text looks great to me.
-Peff
Junio C Hamano· Feb 16, 2023, 02:58 UTC · re: Jeff King · lore

Re: [PATCH v2] rev-list: clarify git-log default date format

Jeff King <peff@peff.net> writes:
Show 24 quoted lines
> On Wed, Feb 15, 2023 at 04:42:25PM -0800, Junio C Hamano wrote:
>
>> The documentation mistakenly said that the default format was
>> similar to RFC 2822 format and tried to specify it by enumerating
>> differences, which had two problems:
>> 
>>  * There are some more differences from the 2822 format that are not
>>    mentioned; worse yet
>> 
>>  * The default format is not modeled after RFC 2822 format at all.
>>    As can be seen in f80cd783 (date.c: add "show_date()" function.,
>>    2005-05-06), it is a derivative of ctime(3) format.
>> 
>> Stop saying that it is similar to RFC 2822, and rewrite the
>> description to explain the format without requiring the reader to
>> know any other format.
>> 
>> Signed-off-by: Junio C Hamano <gitster@pobox.com>
>> ---
>>  * The discussion stalled and the topic was left in limbo for a few
>>    weeks.  Let's attempt to reboot it instead of silently waiting
>>    for a rerolled version from the original author.
>
> Thanks for keeping this moving. The proposed text looks great to me.

Thanks, but the formatting is broken, and needs a line with "--" on it at the end. What I will queue on 'seen' already has the correction.

Junio C Hamano· Feb 16, 2023, 16:29 UTC · re: Junio C Hamano · lore

[PATCH v3] rev-list: clarify git-log default date format

The documentation mistakenly said that the default format was similar to RFC 2822 format and tried to specify it by enumerating differences, which had two problems:

 * There are some more differences from the 2822 format that are not
   mentioned; worse yet
 * The default format is not modeled after RFC 2822 format at all.
   As can be seen in f80cd783 (date.c: add "show_date()" function.,
   2005-05-06), it is a derivative of ctime(3) format.

Stop saying that it is similar to RFC 2822, and rewrite the description to explain the format without requiring the reader to know any other format.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 * The same text as the previous one; only to correct the lack of
   "--" at the end in v2 that broke the formatting toolchain.
 Documentation/rev-list-options.txt | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
Show changes to Documentation/rev-list-options.txt +5 −5
diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt
index ff68e48406..0d90d5b154 100644
--- a/Documentation/rev-list-options.txt
+++ b/Documentation/rev-list-options.txt
@@ -1100,12 +1100,12 @@ preferred format.  See the `strftime` manual for a complete list of
 format placeholders. When using `-local`, the correct syntax is
 `--date=format-local:...`.
 
-`--date=default` is the default format, and is similar to
-`--date=rfc2822`, with a few exceptions:
+`--date=default` is the default format, and is based on ctime(3)
+output.  It shows a single line with three-letter day of the week,
+three-letter month, day-of-month, hour-minute-seconds in "HH:MM:SS"
+format, followed by 4-digit year, plus timezone information, unless
+the local time zone is used, e.g. `Thu Jan 1 00:00:00 1970 +0000`.
 --
-	- there is no comma after the day-of-week
-
-	- the time zone is omitted when the local time zone is used
 
 ifdef::git-rev-list[]
 --header::
-- 
2.39.2-501-gd9d677b2d8
Jeff King· Feb 16, 2023, 17:24 UTC · re: Junio C Hamano · lore

Re: [PATCH v3] rev-list: clarify git-log default date format

On Thu, Feb 16, 2023 at 08:29:25AM -0800, Junio C Hamano wrote:
>  * The same text as the previous one; only to correct the lack of
>    "--" at the end in v2 that broke the formatting toolchain.

Thanks. I looked at this version under doc-diff as well as the HTML version and confirmed that it looks good (which I'm sure you also did at this point ;) ).

-Peff

← back to recent threads