Merge branch 'jk/reflog-date'
The reflog output format is documented better, and a new format --date=unix to report the seconds-since-epoch (without timezone) has been added. * jk/reflog-date: date: clarify --date=raw description date: add "unix" format date: document and test "raw-local" mode doc/pretty-formats: explain shortening of %gd doc/pretty-formats: describe index/time formats for %gd doc/rev-list-options: explain "-g" output formats doc/rev-list-options: clarify "commit@{Nth}" for "-g" option
This commit is contained in:
commit
0d3279962a
@ -147,8 +147,14 @@ endif::git-rev-list[]
|
|||||||
"U" for a good signature with unknown validity and "N" for no signature
|
"U" for a good signature with unknown validity and "N" for no signature
|
||||||
- '%GS': show the name of the signer for a signed commit
|
- '%GS': show the name of the signer for a signed commit
|
||||||
- '%GK': show the key used to sign a signed commit
|
- '%GK': show the key used to sign a signed commit
|
||||||
- '%gD': reflog selector, e.g., `refs/stash@{1}`
|
- '%gD': reflog selector, e.g., `refs/stash@{1}` or
|
||||||
- '%gd': shortened reflog selector, e.g., `stash@{1}`
|
`refs/stash@{2 minutes ago`}; the format follows the rules described
|
||||||
|
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
|
||||||
- '%gN': reflog identity name (respecting .mailmap, see
|
- '%gN': reflog identity name (respecting .mailmap, see
|
||||||
linkgit:git-shortlog[1] or linkgit:git-blame[1])
|
linkgit:git-shortlog[1] or linkgit:git-blame[1])
|
||||||
|
@ -252,10 +252,25 @@ list.
|
|||||||
+
|
+
|
||||||
With `--pretty` format other than `oneline` (for obvious reasons),
|
With `--pretty` format other than `oneline` (for obvious reasons),
|
||||||
this causes the output to have two extra lines of information
|
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. The reflog designator in the output may be shown
|
||||||
used in the output. When the starting commit is specified as
|
as `ref@{Nth}` (where `Nth` is the reverse-chronological index in the
|
||||||
'commit@\{now}', output also uses 'commit@\{timestamp}' notation
|
reflog) or as `ref@{timestamp}` (with the timestamp for that entry),
|
||||||
instead. Under `--pretty=oneline`, the commit message is
|
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.
|
prefixed with this information on the same line.
|
||||||
This option cannot be combined with `--reverse`.
|
This option cannot be combined with `--reverse`.
|
||||||
See also linkgit:git-reflog[1].
|
See also linkgit:git-reflog[1].
|
||||||
@ -714,8 +729,8 @@ include::pretty-options.txt[]
|
|||||||
`iso-local`), the user's local time zone is used instead.
|
`iso-local`), the user's local time zone is used instead.
|
||||||
+
|
+
|
||||||
`--date=relative` shows dates relative to the current time,
|
`--date=relative` shows dates relative to the current time,
|
||||||
e.g. ``2 hours ago''. The `-local` option cannot be used with
|
e.g. ``2 hours ago''. The `-local` option has no effect for
|
||||||
`--raw` or `--relative`.
|
`--date=relative`.
|
||||||
+
|
+
|
||||||
`--date=local` is an alias for `--date=default-local`.
|
`--date=local` is an alias for `--date=default-local`.
|
||||||
+
|
+
|
||||||
@ -735,7 +750,18 @@ format, often found in email messages.
|
|||||||
+
|
+
|
||||||
`--date=short` shows only the date, but not the time, in `YYYY-MM-DD` format.
|
`--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 as seconds since the epoch (1970-01-01
|
||||||
|
00:00:00 UTC), followed by a space, and then the timezone as an offset
|
||||||
|
from UTC (a `+` or `-` with four digits; the first two are hours, and
|
||||||
|
the second two are minutes). I.e., as if the timestamp were formatted
|
||||||
|
with `strftime("%s %z")`).
|
||||||
|
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`.
|
`--date=format:...` feeds the format `...` to your system `strftime`.
|
||||||
Use `--date=format:%c` to show the date in your system locale's
|
Use `--date=format:%c` to show the date in your system locale's
|
||||||
|
@ -2633,6 +2633,9 @@ parse_done:
|
|||||||
case DATE_RAW:
|
case DATE_RAW:
|
||||||
blame_date_width = sizeof("1161298804 -0700");
|
blame_date_width = sizeof("1161298804 -0700");
|
||||||
break;
|
break;
|
||||||
|
case DATE_UNIX:
|
||||||
|
blame_date_width = sizeof("1161298804");
|
||||||
|
break;
|
||||||
case DATE_SHORT:
|
case DATE_SHORT:
|
||||||
blame_date_width = sizeof("2006-10-19");
|
blame_date_width = sizeof("2006-10-19");
|
||||||
break;
|
break;
|
||||||
|
3
cache.h
3
cache.h
@ -1230,7 +1230,8 @@ struct date_mode {
|
|||||||
DATE_ISO8601_STRICT,
|
DATE_ISO8601_STRICT,
|
||||||
DATE_RFC2822,
|
DATE_RFC2822,
|
||||||
DATE_STRFTIME,
|
DATE_STRFTIME,
|
||||||
DATE_RAW
|
DATE_RAW,
|
||||||
|
DATE_UNIX
|
||||||
} type;
|
} type;
|
||||||
const char *strftime_fmt;
|
const char *strftime_fmt;
|
||||||
int local;
|
int local;
|
||||||
|
8
date.c
8
date.c
@ -177,6 +177,12 @@ const char *show_date(unsigned long time, int tz, const struct date_mode *mode)
|
|||||||
struct tm *tm;
|
struct tm *tm;
|
||||||
static struct strbuf timebuf = STRBUF_INIT;
|
static struct strbuf timebuf = STRBUF_INIT;
|
||||||
|
|
||||||
|
if (mode->type == DATE_UNIX) {
|
||||||
|
strbuf_reset(&timebuf);
|
||||||
|
strbuf_addf(&timebuf, "%lu", time);
|
||||||
|
return timebuf.buf;
|
||||||
|
}
|
||||||
|
|
||||||
if (mode->local)
|
if (mode->local)
|
||||||
tz = local_tzoffset(time);
|
tz = local_tzoffset(time);
|
||||||
|
|
||||||
@ -792,6 +798,8 @@ static enum date_mode_type parse_date_type(const char *format, const char **end)
|
|||||||
return DATE_NORMAL;
|
return DATE_NORMAL;
|
||||||
if (skip_prefix(format, "raw", end))
|
if (skip_prefix(format, "raw", end))
|
||||||
return DATE_RAW;
|
return DATE_RAW;
|
||||||
|
if (skip_prefix(format, "unix", end))
|
||||||
|
return DATE_UNIX;
|
||||||
if (skip_prefix(format, "format", end))
|
if (skip_prefix(format, "format", end))
|
||||||
return DATE_STRFTIME;
|
return DATE_STRFTIME;
|
||||||
|
|
||||||
|
@ -46,7 +46,10 @@ check_show rfc2822 "$TIME" 'Wed, 15 Jun 2016 16:13:20 +0200'
|
|||||||
check_show short "$TIME" '2016-06-15'
|
check_show short "$TIME" '2016-06-15'
|
||||||
check_show default "$TIME" 'Wed Jun 15 16:13:20 2016 +0200'
|
check_show default "$TIME" 'Wed Jun 15 16:13:20 2016 +0200'
|
||||||
check_show raw "$TIME" '1466000000 +0200'
|
check_show raw "$TIME" '1466000000 +0200'
|
||||||
|
check_show unix "$TIME" '1466000000'
|
||||||
check_show iso-local "$TIME" '2016-06-15 14:13:20 +0000'
|
check_show iso-local "$TIME" '2016-06-15 14:13:20 +0000'
|
||||||
|
check_show raw-local "$TIME" '1466000000 +0000'
|
||||||
|
check_show unix-local "$TIME" '1466000000'
|
||||||
|
|
||||||
# arbitrary time absurdly far in the future
|
# arbitrary time absurdly far in the future
|
||||||
FUTURE="5758122296 -0400"
|
FUTURE="5758122296 -0400"
|
||||||
|
Loading…
Reference in New Issue
Block a user