Skip to contentSkip to conversation

rev-list: clarify git-log default date format

PATCH In review Rafael Dulfer 4 participants 13 messages Feb 1, 2023 – Feb 16, 2023 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rev-list: clarify git-log default date format

From: Rafael Dulfer <[email protected]>

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)

---
 Documentation/rev-list-options.txt | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
Documentation/rev-list-options.txt +8 -2
index ff68e48406..8bc8475f3e 100644
@@ -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::
Signature · 1 line
2.39.1
#1 lore raw
Quoted 5 lines · Rafael Dulfer

From: Rafael Dulfer <[email protected]>

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.

Quoted 15 lines
---
 Documentation/rev-list-options.txt | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
Documentation/rev-list-options.txt +0 -1
index ff68e48406..8bc8475f3e 100644
@@ -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

Documentation/rev-list-options.txt format placeholders. When using `-local`, the correct syntax is · line 1114

Quoted 10 lines
Documentation/rev-list-options.txt +8 -1
+	- 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.

#2 lore raw
Quoted 16 lines · Junio C Hamano

Documentation/rev-list-options.txt format placeholders. When using `-local`, the correct syntax is · line 1114

Quoted 11 lines
Documentation/rev-list-options.txt +8 -2
-	- 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

Quoted 7 lines

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

#3 lore raw
In reply to Junio C Hamano
Quoted 46 lines · Junio C Hamano
Quoted 11 lines · Rafael Dulfer

From: Rafael Dulfer <[email protected]>

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.

Quoted 15 lines
---
 Documentation/rev-list-options.txt | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
Documentation/rev-list-options.txt +0 -1
index ff68e48406..8bc8475f3e 100644
@@ -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

Documentation/rev-list-options.txt format placeholders. When using `-local`, the correct syntax is · line 1114

Quoted 10 lines
Documentation/rev-list-options.txt +8 -1
+	- 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

Quoted 7 lines

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'.

#4 lore raw
Quoted 8 lines · Ævar Arnfjörð Bjarmason
Quoted 8 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").

Quoted 6 lines
Quoted 1 line

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 ;-)

Quoted 8 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        |
	|---------------+--------------------------------|
#5 lore raw
Quoted 1 line

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)

Quoted 25 lines · Junio C Hamano
Quoted 8 lines · Ævar Arnfjörð Bjarmason
Quoted 8 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").

Quoted 5 lines
Quoted 1 line

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 ;-)

Quoted 8 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        |
	|---------------+--------------------------------|
#6 lore raw
Quoted 2 lines · Rafael Dulfer

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.

#7 lore raw
Quoted 10 lines · Junio C Hamano
Quoted 2 lines · Rafael Dulfer

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.

#8 lore raw

PATCH v2 1/1 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.

---
* 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(-)
Documentation/rev-list-options.txt +5 -6
index ff68e48406..9ae7ccdaa9 100644
@@ -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::
Signature · 1 line
2.39.2-456-gb1485644f9
#9 lore raw
Quoted 15 lines · Junio C Hamano

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.

Quoted 5 lines

---
* 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

#10 lore raw
Quoted 17 lines · Jeff King
Quoted 15 lines · Junio C Hamano

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.

Quoted 7 lines
Quoted 5 lines

---
* 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.

#11 lore raw

PATCH v3 1/1 rev-list: clarify git-log default date format

In reply to Junio C Hamano

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.

---
* 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(-)
Documentation/rev-list-options.txt +5 -5
index ff68e48406..0d90d5b154 100644
@@ -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::
Signature · 1 line
2.39.2-501-gd9d677b2d8
#12 lore raw
Quoted 2 lines · Junio C Hamano

* 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