Skip to content

Commit f16a466

Browse files
committed
Merge branch 'zh/pretty-date-human'
"git log --format=..." placeholders learned %ah/%ch placeholders to request the --date=human output. * zh/pretty-date-human: pretty: provide human date format
2 parents c108c8c + b722d45 commit f16a466

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

Documentation/pretty-formats.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ The placeholders are:
190190
'%ai':: author date, ISO 8601-like format
191191
'%aI':: author date, strict ISO 8601 format
192192
'%as':: author date, short format (`YYYY-MM-DD`)
193+
'%ah':: author date, human style (like the `--date=human` option of
194+
linkgit:git-rev-list[1])
193195
'%cn':: committer name
194196
'%cN':: committer name (respecting .mailmap, see
195197
linkgit:git-shortlog[1] or linkgit:git-blame[1])
@@ -206,6 +208,8 @@ The placeholders are:
206208
'%ci':: committer date, ISO 8601-like format
207209
'%cI':: committer date, strict ISO 8601 format
208210
'%cs':: committer date, short format (`YYYY-MM-DD`)
211+
'%ch':: committer date, human style(like the `--date=human` option of
212+
linkgit:git-rev-list[1])
209213
'%d':: ref names, like the --decorate option of linkgit:git-log[1]
210214
'%D':: ref names without the " (", ")" wrapping.
211215
'%(describe[:options])':: human-readable name, like

pretty.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,9 @@ static size_t format_person_part(struct strbuf *sb, char part,
745745
case 'I': /* date, ISO 8601 strict */
746746
strbuf_addstr(sb, show_ident_date(&s, DATE_MODE(ISO8601_STRICT)));
747747
return placeholder_len;
748+
case 'h': /* date, human */
749+
strbuf_addstr(sb, show_ident_date(&s, DATE_MODE(HUMAN)));
750+
return placeholder_len;
748751
case 's':
749752
strbuf_addstr(sb, show_ident_date(&s, DATE_MODE(SHORT)));
750753
return placeholder_len;

t/t4205-log-pretty-formats.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,12 @@ test_expect_success '--date=short %ad%cd is the same as %as%cs' '
538538
test_cmp expected actual
539539
'
540540

541+
test_expect_success '--date=human %ad%cd is the same as %ah%ch' '
542+
git log --format=%ad%n%cd --date=human >expected &&
543+
git log --format=%ah%n%ch >actual &&
544+
test_cmp expected actual
545+
'
546+
541547
# get new digests (with no abbreviations)
542548
test_expect_success 'set up log decoration tests' '
543549
head1=$(git rev-parse --verify HEAD~0) &&

0 commit comments

Comments
 (0)