From: Jeff King <hidden> Date: 2016-07-22 19:51:14
This is a repost of the patches in:
http://thread.gmane.org/gmane.comp.version-control.git/299201/focus=299236
since I don't think they got picked up at all.
The contents are the same, but with one extra patch (the 4th) that was
posted mid-discussion.
The only other review comment is that patch 5 might want to editorialize
the weirdness of "raw-local" more. I think I'm comfortable leaving it
as-is based on my response in:
http://article.gmane.org/gmane.comp.version-control.git/299312
but I could be persuaded otherwise.
The final patch, "--date=unix" doesn't _really_ solve Ted's problem,
because there's still no way to give multiple date formats in the same
line, nor use "%gd" as both the reflog index and as the date. So I'm
assuming he'll still build "%gt" or similar on top of this, and only in
the long run will we get to "%(reflog-date:unix)" or whatever.
So I think it's still valuable as a minor feature for other formatting
needs, and as a potential building block for later. The earlier patches
are all immediately useful as clarifications.
[1/6]: doc/rev-list-options: clarify "commit@{Nth}" for "-g" option
[2/6]: doc/rev-list-options: explain "-g" output formats
[3/6]: doc/pretty-formats: describe index/time formats for %gd
[4/6]: doc/pretty-formats: explain shortening of %gd
[5/6]: date: document and test "raw-local" mode
[6/6]: date: add "unix" format
-Peff
From: Jeff King <hidden> Date: 2016-07-22 19:51:26
When "log -g" shows "HEAD@{1}", "HEAD@{2}", etc, calling
that "commit@{Nth}" is not really accurate. The "HEAD" part
is really the refname. By saying "commit", a reader may
misunderstand that to mean something related to the specific
commit we are showing, not the ref whose reflog we are
traversing.
While we're here, let's also switch these instances to use
literal backticks, as our style guide recommends. As a
bonus, that lets us drop some asciidoc quoting.
Signed-off-by: Jeff King <redacted>
---
Documentation/rev-list-options.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
@@ -252,9 +252,9 @@ list. + With `--pretty` format other than `oneline` (for obvious reasons), this causes the output to have two extra lines of information-taken from the reflog. By default, 'commit@\{Nth}' notation is+taken from the reflog. By default, `ref@{Nth}` notation is used in the output. When the starting commit is specified as-'commit@\{now}', output also uses 'commit@\{timestamp}' notation+`ref@{now}`, output also uses `ref@{timestamp}` notation instead. Under `--pretty=oneline`, the commit message is prefixed with this information on the same line. This option cannot be combined with `--reverse`.
From: Jeff King <hidden> Date: 2016-07-22 19:51:52
We document that asking for HEAD@{now} will switch the
output to show HEAD@{timestamp}, but not that specifying
`--date` has a similar effect, or that it can be overridden
with HEAD@{0}. Let's do so.
These rules come from 794151e (reflog-walk: always make
HEAD@{0} show indexed selectors, 2012-05-04), though that is
simply the culmination of years of these heuristics growing
organically.
Signed-off-by: Jeff King <redacted>
---
Documentation/rev-list-options.txt | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
@@ -252,10 +252,25 @@ list. + With `--pretty` format other than `oneline` (for obvious reasons), this causes the output to have two extra lines of information-taken from the reflog. By default, `ref@{Nth}` notation is-used in the output. When the starting commit is specified as-`ref@{now}`, output also uses `ref@{timestamp}` notation-instead. Under `--pretty=oneline`, the commit message is+taken from the reflog. The reflog designator in the output may be shown+as `ref@{Nth}` (where `Nth` is the reverse-chronological index in the+reflog) or as `ref@{timestamp}` (with the timestamp for that entry),+depending on a few rules:+++--+1. If the starting point is specified as `ref@{Nth}`, show the index+format.+++2. If the starting point was specified as `ref@{now}`, show the+timestamp format.+++3. If neither was used, but `--date` was given on the command line, show+the timestamp in the format requested by `--date`.+++4. Otherwise, show the index format.+--+++Under `--pretty=oneline`, the commit message is prefixed with this information on the same line. This option cannot be combined with `--reverse`. See also linkgit:git-reflog[1].
From: Jeff King <hidden> Date: 2016-07-22 19:51:56
The "reflog selector" format changes based on a series of
heuristics, and that applies equally to both stock "log -g"
output, as well as "--format=%gd". The documentation for
"%gd" doesn't cover this. Let's mention the multiple formats
and refer the user back to the "-g" section for the complete
rules.
Signed-off-by: Jeff King <redacted>
---
Documentation/pretty-formats.txt | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
@@ -147,8 +147,11 @@ endif::git-rev-list[] "U" for a good signature with unknown validity and "N" for no signature - '%GS': show the name of the signer for a signed commit - '%GK': show the key used to sign a signed commit-- '%gD': reflog selector, e.g., `refs/stash@{1}`-- '%gd': shortened reflog selector, e.g., `stash@{1}`+- '%gD': reflog selector, e.g., `refs/stash@{1}` or+ `refs/stash@{2 minutes ago`}; the format follows the rules described+ for the `-g` option+- '%gd': shortened reflog selector, e.g., `stash@{1}` or+ `stash@{2 minutes ago}` - '%gn': reflog identity name - '%gN': reflog identity name (respecting .mailmap, see linkgit:git-shortlog[1] or linkgit:git-blame[1])
From: Jeff King <hidden> Date: 2016-07-22 19:51:57
The actual shortening rules aren't that interesting and
probably not worth getting into (I gloss over them here as
"shortened for human readability"). But the fact that %gD
shows whatever you gave on the command line is subtle and
worth mentioning. Since most people will feed a shortened
refname in the first place, it otherwise makes it hard to
understand the difference between the two.
Signed-off-by: Jeff King <redacted>
---
Documentation/pretty-formats.txt | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
@@ -149,9 +149,12 @@ endif::git-rev-list[] - '%GK': show the key used to sign a signed commit - '%gD': reflog selector, e.g., `refs/stash@{1}` or `refs/stash@{2 minutes ago`}; the format follows the rules described- for the `-g` option-- '%gd': shortened reflog selector, e.g., `stash@{1}` or- `stash@{2 minutes ago}`+ for the `-g` option. The portion before the `@` is the refname as+ given on the command line (so `git log -g refs/heads/master` would+ yield `refs/heads/master@{0}`).+- '%gd': shortened reflog selector; same as `%gD`, but the refname+ portion is shortened for human readability (so `refs/heads/master`+ becomes just `master`). - '%gn': reflog identity name - '%gN': reflog identity name (respecting .mailmap, see linkgit:git-shortlog[1] or linkgit:git-blame[1])
From: Jeff King <hidden> Date: 2016-07-22 19:51:58
The "raw" format shows a Unix epoch timestamp, but with a
timezone tacked on. The timestamp is not _in_ that zone, but
it is extra information about the time (by default, the zone
the author was in).
The documentation claims that "raw-local" does not work. It
does, but the end result is rather subtle. Let's describe it
in better detail, and test to make sure it works (namely,
the epoch time doesn't change, but the zone does).
While we are rewording the documentation in this area, let's
not use the phrase "does not work" for the remaining option,
"--relative". It's vague; do we accept it or not? We do
accept it, but it has no effect (which is a reasonable
outcome).
Signed-off-by: Jeff King <redacted>
---
Documentation/rev-list-options.txt | 9 ++++++---
t/t0006-date.sh | 1 +
2 files changed, 7 insertions(+), 3 deletions(-)
@@ -725,8 +725,8 @@ include::pretty-options.txt[] `iso-local`), the user's local time zone is used instead. + `--date=relative` shows dates relative to the current time,-e.g. ``2 hours ago''. The `-local` option cannot be used with-`--raw` or `--relative`.+e.g. ``2 hours ago''. The `-local` option has no effect for+`--relative`. + `--date=local` is an alias for `--date=default-local`. +
@@ -746,7 +746,10 @@ format, often found in email messages. + `--date=short` shows only the date, but not the time, in `YYYY-MM-DD` format. +-`--date=raw` shows the date in the internal raw Git format `%s %z` format.+`--date=raw` shows the date in the internal raw Git format `%s %z`+format. Note that the `-local` option does not affect the+seconds-since-epoch value (which is always measured in UTC), but does+switch the accompanying timezone value. + `--date=format:...` feeds the format `...` to your system `strftime`. Use `--date=format:%c` to show the date in your system locale's
@@ -47,6 +47,7 @@ check_show short "$TIME" '2016-06-15' check_showdefault"$TIME"'Wed Jun 15 16:13:20 2016 +0200' check_showraw"$TIME"'1466000000 +0200' check_showiso-local"$TIME"'2016-06-15 14:13:20 +0000'+check_showraw-local"$TIME"'1466000000 +0000'# arbitrary time absurdly far in the futureFUTURE="5758122296 -0400"
From: Jeff King <hidden> Date: 2016-07-22 19:52:04
We already have "--date=raw", which is a Unix epoch
timestamp plus a contextual timezone (either the author's or
the local). But one may not care about the timezone and just
want the epoch timestamp by itself. It's not hard to parse
the two apart, but if you are using a pretty-print format,
you may want git to show the "finished" form that the user
will see.
We can accomodate this by adding a new date format, "unix",
which is basically "raw" without the timezone.
Signed-off-by: Jeff King <redacted>
---
Documentation/rev-list-options.txt | 4 ++++
builtin/blame.c | 3 +++
cache.h | 3 ++-
date.c | 8 ++++++++
t/t0006-date.sh | 2 ++
5 files changed, 19 insertions(+), 1 deletion(-)
@@ -751,6 +751,10 @@ format. Note that the `-local` option does not affect the seconds-since-epoch value (which is always measured in UTC), but does switch the accompanying timezone value. ++`--date=unix` shows the date as a Unix epoch timestamp (seconds since+1970). As with `--raw`, this is always in UTC and therefore `-local`+has no effect.++ `--date=format:...` feeds the format `...` to your system `strftime`. Use `--date=format:%c` to show the date in your system locale's preferred format. See the `strftime` manual for a complete list of
@@ -177,6 +177,12 @@ const char *show_date(unsigned long time, int tz, const struct date_mode *mode)structtm*tm;staticstructstrbuftimebuf=STRBUF_INIT;+if(mode->type==DATE_UNIX){+strbuf_reset(&timebuf);+strbuf_addf(&timebuf,"%lu",time);+returntimebuf.buf;+}+if(mode->local)tz=local_tzoffset(time);
From: Jakub Narębski <hidden> Date: 2016-07-23 10:15:55
W dniu 2016-07-22 o 21:51, Jeff King pisze:
The "raw" format shows a Unix epoch timestamp, but with a
timezone tacked on. The timestamp is not _in_ that zone, but
it is extra information about the time (by default, the zone
the author was in).
I would say that "Unix time" (name according to Wikipedia) is
zone-less, but the information is correct.
The documentation claims that "raw-local" does not work. It
does, but the end result is rather subtle. Let's describe it
in better detail, and test to make sure it works (namely,
the epoch time doesn't change, but the zone does).
Subtle, and not very useful (unless you want to know your
own timezone difference)... or do we adjust timezone offset
shown across DST change for the locale?
While we are rewording the documentation in this area, let's
not use the phrase "does not work" for the remaining option,
"--relative". It's vague; do we accept it or not? We do
accept it, but it has no effect (which is a reasonable
outcome).
Anyway, replacing vague "does not work" with explanation of
what is the result is a very good idea.
quoted hunk
Signed-off-by: Jeff King <redacted>
---
Documentation/rev-list-options.txt | 9 ++++++---
t/t0006-date.sh | 1 +
2 files changed, 7 insertions(+), 3 deletions(-)
@@ -725,8 +725,8 @@ include::pretty-options.txt[] `iso-local`), the user's local time zone is used instead. + `--date=relative` shows dates relative to the current time,-e.g. ``2 hours ago''. The `-local` option cannot be used with-`--raw` or `--relative`.+e.g. ``2 hours ago''. The `-local` option has no effect for+`--relative`.
Do I understand it correctly: --relative is a short form for more
generic --date=relative (which probably should be spelled
--date-format=relative), and that --date=relative-local is the
same as --date=relative, that is *-local suffix does not change
how date is formatted?
Because I don't think you can say --relative-local ("The `-local`
option has no effect on `--relative`"), can you?
Nevertheless the proposed change is definite improvement.
quoted hunk
+
`--date=local` is an alias for `--date=default-local`.
+
@@ -746,7 +746,10 @@ format, often found in email messages. + `--date=short` shows only the date, but not the time, in `YYYY-MM-DD` format. +-`--date=raw` shows the date in the internal raw Git format `%s %z` format.+`--date=raw` shows the date in the internal raw Git format `%s %z`+format. Note that the `-local` option does not affect the+seconds-since-epoch value (which is always measured in UTC), but does+switch the accompanying timezone value.
Which is correct, logical, and next to useless, I think.
BTW. one kind of format that Git does not support (I think) is the
varying kind, where the precision changes with the distance from now,
so that we can get most precision in limited width. That's what
`ls --long` does:
* 'Jun 29 16:47' for dates falling in current year (more precision)
* 'Nov 23 2015' for dates outside (less precision, same width)
Many other programs switch from relative to absolute time when date
in question is far in the past that relative is not very good.
quoted hunk
+
`--date=format:...` feeds the format `...` to your system `strftime`.
Use `--date=format:%c` to show the date in your system locale's
@@ -47,6 +47,7 @@ check_show short "$TIME" '2016-06-15' check_showdefault"$TIME"'Wed Jun 15 16:13:20 2016 +0200' check_showraw"$TIME"'1466000000 +0200' check_showiso-local"$TIME"'2016-06-15 14:13:20 +0000'+check_showraw-local"$TIME"'1466000000 +0000'# arbitrary time absurdly far in the futureFUTURE="5758122296 -0400"
@@ -725,8 +725,8 @@ include::pretty-options.txt[] `iso-local`), the user's local time zone is used instead. + `--date=relative` shows dates relative to the current time,-e.g. ``2 hours ago''. The `-local` option cannot be used with-`--raw` or `--relative`.+e.g. ``2 hours ago''. The `-local` option has no effect for+`--relative`.
Do I understand it correctly: --relative is a short form for more
generic --date=relative (which probably should be spelled
--date-format=relative), and that --date=relative-local is the
same as --date=relative, that is *-local suffix does not change
how date is formatted?
Because I don't think you can say --relative-local ("The `-local`
option has no effect on `--relative`"), can you?
All correct. There is no --relative-local because "--relative" is a
historical artifact. We could support --foo for every --date=foo, but I
don't think there is a reason to do so (and reasons not to, like
avoiding cluttering the option space).
quoted
-`--date=raw` shows the date in the internal raw Git format `%s %z` format.
+`--date=raw` shows the date in the internal raw Git format `%s %z`
+format. Note that the `-local` option does not affect the
+seconds-since-epoch value (which is always measured in UTC), but does
+switch the accompanying timezone value.
Which is correct, logical, and next to useless, I think.
This was discussed in the earlier review. It's basically only useful if
you are feeding the output to another script which will format the date
and want to change what that script shows.
BTW. one kind of format that Git does not support (I think) is the
varying kind, where the precision changes with the distance from now,
so that we can get most precision in limited width. That's what
`ls --long` does:
* 'Jun 29 16:47' for dates falling in current year (more precision)
* 'Nov 23 2015' for dates outside (less precision, same width)
Many other programs switch from relative to absolute time when date
in question is far in the past that relative is not very good.
Yes, this was discussed on the list not too long ago. I think it would
be useful, but is obviously orthogonal to this series.
-Peff
@@ -725,8 +725,8 @@ include::pretty-options.txt[] `iso-local`), the user's local time zone is used instead. + `--date=relative` shows dates relative to the current time,-e.g. ``2 hours ago''. The `-local` option cannot be used with-`--raw` or `--relative`.+e.g. ``2 hours ago''. The `-local` option has no effect for+`--relative`.
Do I understand it correctly: --relative is a short form for more
generic --date=relative (which probably should be spelled
--date-format=relative), and that --date=relative-local is the
same as --date=relative, that is *-local suffix does not change
how date is formatted?
Because I don't think you can say --relative-local ("The `-local`
option has no effect on `--relative`"), can you?
All correct. There is no --relative-local because "--relative" is a
historical artifact. We could support --foo for every --date=foo, but I
don't think there is a reason to do so (and reasons not to, like
avoiding cluttering the option space).
So shouldn't the last sentence
"The `-local` option has no effect for `--relative`."
be rather
"The `-local` option has no effect for `--date=relative`."
Though this might be just me being overly nitpicky...
--
Jakub Narębski
From: Jeff King <hidden> Date: 2016-07-27 13:44:48
On Wed, Jul 27, 2016 at 02:35:08PM +0200, Jakub Narębski wrote:
quoted
All correct. There is no --relative-local because "--relative" is a
historical artifact. We could support --foo for every --date=foo, but I
don't think there is a reason to do so (and reasons not to, like
avoiding cluttering the option space).
So shouldn't the last sentence
"The `-local` option has no effect for `--relative`."
be rather
"The `-local` option has no effect for `--date=relative`."
Ah, I see. I didn't realize that's what you are getting at. Yes, it
would be more accurate. That's not a new problem introduced by my patch;
I just happened to be touching that sentence for other reasons. But the
patch does try to clean up the text in general, so it seems like a good
time to make this fix, too.
Since it looks like this is not even in 'next' yet, here is a
replacement for the 5th patch (second from the top) of the
jk/reflog-date topic.
-- >8 --
Subject: [PATCH] date: document and test "raw-local" mode
The "raw" format shows a Unix epoch timestamp, but with a
timezone tacked on. The timestamp is not _in_ that zone, but
it is extra information about the time (by default, the zone
the author was in).
The documentation claims that "raw-local" does not work. It
does, but the end result is rather subtle. Let's describe it
in better detail, and test to make sure it works (namely,
the epoch time doesn't change, but the zone does).
While we are rewording the documentation in this area, let's
not use the phrase "does not work" for the remaining option,
"--date=relative". It's vague; do we accept it or not? We do
accept it, but it has no effect (which is a reasonable
outcome). We should also refer to the option not as
"--relative" (which is the historical synonym, and does not
take "-local" at all), but as "--date=relative".
Helped-by: Jakub Narębski [off-list ref]
Signed-off-by: Jeff King <redacted>
---
Documentation/rev-list-options.txt | 9 ++++++---
t/t0006-date.sh | 1 +
2 files changed, 7 insertions(+), 3 deletions(-)
@@ -725,8 +725,8 @@ include::pretty-options.txt[] `iso-local`), the user's local time zone is used instead. + `--date=relative` shows dates relative to the current time,-e.g. ``2 hours ago''. The `-local` option cannot be used with-`--raw` or `--relative`.+e.g. ``2 hours ago''. The `-local` option has no effect for+`--date=relative`. + `--date=local` is an alias for `--date=default-local`. +
@@ -746,7 +746,10 @@ format, often found in email messages. + `--date=short` shows only the date, but not the time, in `YYYY-MM-DD` format. +-`--date=raw` shows the date in the internal raw Git format `%s %z` format.+`--date=raw` shows the date in the internal raw Git format `%s %z`+format. Note that the `-local` option does not affect the+seconds-since-epoch value (which is always measured in UTC), but does+switch the accompanying timezone value. + `--date=format:...` feeds the format `...` to your system `strftime`. Use `--date=format:%c` to show the date in your system locale's
@@ -47,6 +47,7 @@ check_show short "$TIME" '2016-06-15' check_showdefault"$TIME"'Wed Jun 15 16:13:20 2016 +0200' check_showraw"$TIME"'1466000000 +0200' check_showiso-local"$TIME"'2016-06-15 14:13:20 +0000'+check_showraw-local"$TIME"'1466000000 +0000'# arbitrary time absurdly far in the futureFUTURE="5758122296 -0400"