为什么 --date= 会影响 %gd git 日志格式?

Why does --date= affect the %gd git log format?

$ git stash list --format="%gd, %cd"
stash@{0}, Fri Sep 22 11:40:25 2017 +0100
stash@{1}, Mon Sep 18 16:12:11 2017 +0100

隐藏 ID 和长格式日期。如果我尝试获得较短的约会:

$ git stash list --format="%gd, %cd" --date=short
stash@{2017-09-22}, 2017-09-22
stash@{2017-09-18}, 2017-09-18

为什么stash id也变成了日期? %cddocumented 以尊重 --date=,但不是 %gd(无论如何它都不应该显示日期)。

%gD: reflog selector, e.g., refs/stash@{1} or 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).

所以%gd%gD相同,%gD的格式遵循-g的规则。我们来看看-g.

-g

--walk-reflogs

Instead of walking the commit ancestry chain, walk reflog entries from the most recent one to older ones. When this option is used you cannot specify commits to exclude (that is, ^commit, commit1..commit2, and commit1...commit2 notations cannot be used).

With --pretty format other than oneline (for obvious reasons), this causes the output to have two extra lines of information 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:

If the starting point is specified as ref@{Nth}, show the index format.

If the starting point was specified as ref@{now}, show the timestamp format.

If neither was used, but --date was given on the command line, show the timestamp in the format requested by --date.

Otherwise, show the index format.

所以这是有道理的。