pretty: provide human date format
PATCH 1/1 pretty: provide human date format
From: ZheNing Hu <[email protected]>
Add the placeholders %ah and %ch to format author date and committer date, like --date=human does, which provides more humanity date output.
---
[GSOC] pretty: provide human date format
Reasons for making this patch: --date=human has no corresponding --pretty option.
Although --date=human with --pretty="%(a|c)d" can achieve the same effect with --pretty="%(a|c)h", but it can be noticed that most time formats implement the corresponding option of --pretty, such as --date=iso8601 can be replaced by --pretty=%(a|c)i, so add "--pretty=%(a|c)h" seems to be a very reasonable thing.
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-939%2Fadlternative%2Fpretty_human-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-939/adlternative/pretty_human-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/939
Documentation/pretty-formats.txt | 2 ++ pretty.c | 3 +++ t/t4205-log-pretty-formats.sh | 6 ++++++ 3 files changed, 11 insertions(+)
Documentation/pretty-formats.txt +2 -0
@@ -190,6 +190,7 @@ The placeholders are: '%ai':: author date, ISO 8601-like format '%aI':: author date, strict ISO 8601 format '%as':: author date, short format (`YYYY-MM-DD`) +'%ah':: author date, human style '%cn':: committer name '%cN':: committer name (respecting .mailmap, see linkgit:git-shortlog[1] or linkgit:git-blame[1])
@@ -206,6 +207,7 @@ The placeholders are: '%ci':: committer date, ISO 8601-like format '%cI':: committer date, strict ISO 8601 format '%cs':: committer date, short format (`YYYY-MM-DD`) +'%ch':: committer date, human style '%d':: ref names, like the --decorate option of linkgit:git-log[1] '%D':: ref names without the " (", ")" wrapping. '%(describe[:options])':: human-readable name, like
pretty.c +3 -0
@@ -745,6 +745,9 @@ static size_t format_person_part(struct strbuf *sb, char part,case 'I' :/* date, ISO 8601 strict */ strbuf_addstr (sb,show_ident_date (&s,DATE_MODE (ISO8601_STRICT )));return placeholder_len; +case 'h' :/* date, human */ +strbuf_addstr (sb,show_ident_date (&s,DATE_MODE (HUMAN ))); +return placeholder_len;case 's' :strbuf_addstr (sb,show_ident_date (&s,DATE_MODE (SHORT )));return placeholder_len;
t/t4205-log-pretty-formats.sh +6 -0
@@ -539,6 +539,12 @@ test_expect_success 'short date' ' test_cmp expected actual ' +test_expect_success 'human date' ' + git log --format=%ad%n%cd --date=human >expected && + git log --format=%ah%n%ch >actual && + test_cmp expected actual +' + # get new digests (with no abbreviations) test_expect_success 'set up log decoration tests' ' head1=$(git rev-parse --verify HEAD~0) &&
base-commit: b0c09ab8796fb736efa432b8e817334f3e5ee75a
Signature · 1 line
gitgitgadget
Hi ZheNing,
Quoted 4 lines · ZheNing Hu via GitGitGadget
From: ZheNing Hu <[email protected]>
Add the placeholders %ah and %ch to format author date and committer date, like --date=human does, which provides more humanity date output.
I don't see a reason why this shouldn't exist, and the patch that you wrote below looks pretty good to me.
To refresh my memory on if you had missed any spots, I followed 0df621172d (pretty: provide short date format, 2019-11-19) as an example. You did a fine job here, and I don't think this patch is missing anything.
Quoted 4 lines
Signed-off-by ZheNing Hu <[email protected]>---
[GSOC] pretty: provide human date format
Quoted 8 lines
Reasons for making this patch: --date=human has no corresponding --pretty option.
Although --date=human with --pretty="%(a|c)d" can achieve the same effect with --pretty="%(a|c)h", but it can be noticed that most time formats implement the corresponding option of --pretty, such as --date=iso8601 can be replaced by --pretty=%(a|c)i, so add "--pretty=%(a|c)h" seems to be a very reasonable thing.
Just to make sure I understand what you wrote: you're saying that the pretty formats "%ah" and "%ch" that you propose here could be achieved with --date=human and --pretty="%ad". Makes sense, but I agree that your point about --date=iso8601 having a built-in pretty atom makes the case for having "%ah" and "%ch".
Quoted 14 lines
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-939%2Fadlternative%2Fpretty_human-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-939/adlternative/pretty_human-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/939Documentation/pretty-formats.txt | 2 ++ pretty.c | 3 +++ t/t4205-log-pretty-formats.sh | 6 ++++++ 3 files changed, 11 insertions(+)Documentation/pretty-formats.txt +0
-0
Documentation/pretty-formats.txt The placeholders are: · line 193
Quoted 4 lines
Documentation/pretty-formats.txt +1
-0@@ -190,6 +190,7 @@ The placeholders are: '%ai':: author date, ISO 8601-like format '%aI':: author date, strict ISO 8601 format '%as':: author date, short format (`YYYY-MM-DD`) +'%ah':: author date, human style
There's no sorting here, so this place (at the bottom of the author-date placeholders) seems just as good as any.
Documentation/pretty-formats.txt The placeholders are: · line 210
Quoted 8 lines
Documentation/pretty-formats.txt +1
-0'%cn':: committer name '%cN':: committer name (respecting .mailmap, see linkgit:git-shortlog[1] or linkgit:git-blame[1])@@ -206,6 +207,7 @@ The placeholders are: '%ci':: committer date, ISO 8601-like format '%cI':: committer date, strict ISO 8601 format '%cs':: committer date, short format (`YYYY-MM-DD`) +'%ch':: committer date, human style
Likewise. The rest all looks good to me, too.
Thanks,
Taylor
Quoted 9 lines · Taylor Blau <[email protected]> 于2021年4月24日周六 上午4:21写道:
Hi ZheNing,
Quoted 4 lines · ZheNing Hu via GitGitGadget
From: ZheNing Hu <[email protected]>
Add the placeholders %ah and %ch to format author date and committer date, like --date=human does, which provides more humanity date output.
Quoted 8 lines
I don't see a reason why this shouldn't exist, and the patch that you wrote below looks pretty good to me.
To refresh my memory on if you had missed any spots, I followed
0df621172d(pretty: provide short date format, 2019-11-19) as an example. You did a fine job here, and I don't think this patch is missing anything.
Yes, I saw René Scharfe's (have --cc) patch and learned handle way from it.
Quoted 13 lines
Quoted 4 lines
Signed-off-by ZheNing Hu <[email protected]>---
[GSOC] pretty: provide human date formatQuoted 8 lines
Reasons for making this patch: --date=human has no corresponding --pretty option.
Although --date=human with --pretty="%(a|c)d" can achieve the same effect with --pretty="%(a|c)h", but it can be noticed that most time formats implement the corresponding option of --pretty, such as --date=iso8601 can be replaced by --pretty=%(a|c)i, so add "--pretty=%(a|c)h" seems to be a very reasonable thing.
Quoted 6 lines
Just to make sure I understand what you wrote: you're saying that the pretty formats "%ah" and "%ch" that you propose here could be achieved with --date=human and --pretty="%ad". Makes sense, but I agree that your point about --date=iso8601 having a built-in pretty atom makes the case for having "%ah" and "%ch".
Yes, I tried to explain that "%(a|c)h" makes sense.
Quoted 33 lines
Quoted 14 lines
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-939%2Fadlternative%2Fpretty_human-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-939/adlternative/pretty_human-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/939Documentation/pretty-formats.txt | 2 ++ pretty.c | 3 +++ t/t4205-log-pretty-formats.sh | 6 ++++++ 3 files changed, 11 insertions(+)Documentation/pretty-formats.txt +0
-0Documentation/pretty-formats.txt The placeholders are: · line 193
Quoted 4 lines
Documentation/pretty-formats.txt +1
-0@@ -190,6 +190,7 @@ The placeholders are: '%ai':: author date, ISO 8601-like format '%aI':: author date, strict ISO 8601 format '%as':: author date, short format (`YYYY-MM-DD`) +'%ah':: author date, human styleThere's no sorting here, so this place (at the bottom of the author-date placeholders) seems just as good as any.
Documentation/pretty-formats.txt The placeholders are: · line 210
Quoted 8 lines
Documentation/pretty-formats.txt +1
-0'%cn':: committer name '%cN':: committer name (respecting .mailmap, see linkgit:git-shortlog[1] or linkgit:git-blame[1])@@ -206,6 +207,7 @@ The placeholders are: '%ci':: committer date, ISO 8601-like format '%cI':: committer date, strict ISO 8601 format '%cs':: committer date, short format (`YYYY-MM-DD`) +'%ch':: committer date, human styleLikewise. The rest all looks good to me, too.
Quoted 4 lines
Reviewed-by Taylor Blau <[email protected]>Thanks,
Taylor
Thanks!
--
ZheNing Hu
Quoted 32 lines · ZheNing Hu via GitGitGadget
From: ZheNing Hu <[email protected]>
Add the placeholders %ah and %ch to format author date and committer date, like --date=human does, which provides more humanity date output.
Signed-off-by ZheNing Hu <[email protected]>---
[GSOC] pretty: provide human date formatReasons for making this patch: --date=human has no corresponding --pretty option.
Although --date=human with --pretty="%(a|c)d" can achieve the same effect with --pretty="%(a|c)h", but it can be noticed that most time formats implement the corresponding option of --pretty, such as --date=iso8601 can be replaced by --pretty=%(a|c)i, so add "--pretty=%(a|c)h" seems to be a very reasonable thing.
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-939%2Fadlternative%2Fpretty_human-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-939/adlternative/pretty_human-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/939Documentation/pretty-formats.txt | 2 ++ pretty.c | 3 +++ t/t4205-log-pretty-formats.sh | 6 ++++++ 3 files changed, 11 insertions(+)Documentation/pretty-formats.txt +0
-0
Documentation/pretty-formats.txt The placeholders are: · line 193
Quoted 4 lines
Documentation/pretty-formats.txt +1
-0@@ -190,6 +190,7 @@ The placeholders are: '%ai':: author date, ISO 8601-like format '%aI':: author date, strict ISO 8601 format '%as':: author date, short format (`YYYY-MM-DD`) +'%ah':: author date, human style
An example may be useful. There's no other mention of human date style in the pretty-formats doc. Or a link to the definitive man page.
Documentation/pretty-formats.txt The placeholders are: · line 210
Quoted 8 lines
Documentation/pretty-formats.txt +1
-0'%cn':: committer name '%cN':: committer name (respecting .mailmap, see linkgit:git-shortlog[1] or linkgit:git-blame[1])@@ -206,6 +207,7 @@ The placeholders are: '%ci':: committer date, ISO 8601-like format '%cI':: committer date, strict ISO 8601 format '%cs':: committer date, short format (`YYYY-MM-DD`) +'%ch':: committer date, human style
Likewise, an (e.g. ????) to unconfuse readers.
Quoted 35 lines
Documentation/pretty-formats.txt +0
-0'%d':: ref names, like the --decorate option of linkgit:git-log[1] '%D':: ref names without the " (", ")" wrapping. '%(describe[:options])':: human-readable name, likepretty.c +3
-0@@ -745,6 +745,9 @@ static size_t format_person_part(struct strbuf *sb, char part,case 'I' :/* date, ISO 8601 strict */ strbuf_addstr (sb,show_ident_date (&s,DATE_MODE (ISO8601_STRICT )));return placeholder_len; +case 'h' :/* date, human */ +strbuf_addstr (sb,show_ident_date (&s,DATE_MODE (HUMAN ))); +return placeholder_len;case 's' :strbuf_addstr (sb,show_ident_date (&s,DATE_MODE (SHORT )));return placeholder_len;t/t4205-log-pretty-formats.sh +6
-0@@ -539,6 +539,12 @@ test_expect_success 'short date' ' test_cmp expected actual ' +test_expect_success 'human date' ' + git log --format=%ad%n%cd --date=human >expected && + git log --format=%ah%n%ch >actual && + test_cmp expected actual +' + # get new digests (with no abbreviations) test_expect_success 'set up log decoration tests' ' head1=$(git rev-parse --verify HEAD~0) &&
Quoted 1 line
base-commit:
b0c09ab8796fb736efa432b8e817334f3e5ee75a
--
Philip
Quoted 29 lines · Philip Oakley <[email protected]> 于2021年4月24日周六 上午5:10写道:
Quoted 27 lines · ZheNing Hu via GitGitGadget
From: ZheNing Hu <[email protected]>
Add the placeholders %ah and %ch to format author date and committer date, like --date=human does, which provides more humanity date output.
Signed-off-by ZheNing Hu <[email protected]>---
[GSOC] pretty: provide human date formatReasons for making this patch: --date=human has no corresponding --pretty option.
Although --date=human with --pretty="%(a|c)d" can achieve the same effect with --pretty="%(a|c)h", but it can be noticed that most time formats implement the corresponding option of --pretty, such as --date=iso8601 can be replaced by --pretty=%(a|c)i, so add "--pretty=%(a|c)h" seems to be a very reasonable thing.
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-939%2Fadlternative%2Fpretty_human-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-939/adlternative/pretty_human-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/939Documentation/pretty-formats.txt | 2 ++ pretty.c | 3 +++ t/t4205-log-pretty-formats.sh | 6 ++++++ 3 files changed, 11 insertions(+)
Quoted 13 lines
Documentation/pretty-formats.txt The placeholders are: · line 193
Quoted 9 lines
Documentation/pretty-formats.txt +1
-0@@ -190,6 +190,7 @@ The placeholders are: '%ai':: author date, ISO 8601-like format '%aI':: author date, strict ISO 8601 format '%as':: author date, short format (`YYYY-MM-DD`) +'%ah':: author date, human styleAn example may be useful. There's no other mention of human date style in the pretty-formats doc. Or a link to the definitive man page.
Thanks for the suggestion. Note that the explanation here is relatively small, and human style has many different situations, so I may just go to link it to rev-list-option.txt, This is more convenient than showing multiple situations' examples.
Quoted 44 lines
Documentation/pretty-formats.txt The placeholders are: · line 210
Quoted 8 lines
Documentation/pretty-formats.txt +1
-0'%cn':: committer name '%cN':: committer name (respecting .mailmap, see linkgit:git-shortlog[1] or linkgit:git-blame[1])@@ -206,6 +207,7 @@ The placeholders are: '%ci':: committer date, ISO 8601-like format '%cI':: committer date, strict ISO 8601 format '%cs':: committer date, short format (`YYYY-MM-DD`) +'%ch':: committer date, human styleLikewise, an
(e.g. ????)to unconfuse readers.Quoted 35 lines
Documentation/pretty-formats.txt +0
-0'%d':: ref names, like the --decorate option of linkgit:git-log[1] '%D':: ref names without the " (", ")" wrapping. '%(describe[:options])':: human-readable name, likepretty.c +3
-0@@ -745,6 +745,9 @@ static size_t format_person_part(struct strbuf *sb, char part,case 'I' :/* date, ISO 8601 strict */ strbuf_addstr (sb,show_ident_date (&s,DATE_MODE (ISO8601_STRICT )));return placeholder_len; +case 'h' :/* date, human */ +strbuf_addstr (sb,show_ident_date (&s,DATE_MODE (HUMAN ))); +return placeholder_len;case 's' :strbuf_addstr (sb,show_ident_date (&s,DATE_MODE (SHORT )));return placeholder_len;t/t4205-log-pretty-formats.sh +6
-0@@ -539,6 +539,12 @@ test_expect_success 'short date' ' test_cmp expected actual ' +test_expect_success 'human date' ' + git log --format=%ad%n%cd --date=human >expected && + git log --format=%ah%n%ch >actual && + test_cmp expected actual +' + # get new digests (with no abbreviations) test_expect_success 'set up log decoration tests' ' head1=$(git rev-parse --verify HEAD~0) &&
Quoted 3 lines
Quoted 1 line
base-commit:
b0c09ab8796fb736efa432b8e817334f3e5ee75a--
Philip
Thanks!
--
ZheNing Hu
PATCH v2 1/1 pretty: provide human date format
In reply to ZheNing Hu via GitGitGadgetFrom: ZheNing Hu <[email protected]>
Add the placeholders %ah and %ch to format author date and committer date, like --date=human does, which provides more humanity date output.
---
[GSOC] pretty: provide human date format
Reasons for making this patch: --date=human has no corresponding --pretty option.
Although --date=human with --pretty="%(a|c)d" can achieve the same effect with --pretty="%(a|c)h", but it can be noticed that most time formats implement the corresponding option of --pretty, such as --date=iso8601 can be replaced by --pretty=%(a|c)i, so add "--pretty=%(a|c)h" seems to be a very reasonable thing.
Change from v1: add %(a|c)h link to rev-list-options.txt.
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-939%2Fadlternative%2Fpretty_human-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-939/adlternative/pretty_human-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/939
Range-diff vs v1:
1: ed8abd6179d1 ! 1: 1517708876b5 [GSOC] pretty: provide human date format
@@ Documentation/pretty-formats.txt: The placeholders are:
'%ai':: author date, ISO 8601-like format
'%aI':: author date, strict ISO 8601 format
'%as':: author date, short format (YYYY-MM-DD)
-+'%ah':: author date, human style
++'%ah':: author date, human style (like the --date=human option of
++ linkgit:rev-list-options.txt[1])
'%cn':: committer name
'%cN':: committer name (respecting .mailmap, see
linkgit:git-shortlog[1] or linkgit:git-blame[1])
@@ Documentation/pretty-formats.txt: The placeholders are:
'%ci':: committer date, ISO 8601-like format
'%cI':: committer date, strict ISO 8601 format
'%cs':: committer date, short format (YYYY-MM-DD)
-+'%ch':: committer date, human style
++'%ch':: committer date, human style(like the --date=human option of
++ linkgit:rev-list-options.txt[1])
'%d':: ref names, like the --decorate option of linkgit:git-log[1] '%D':: ref names without the " (", ")" wrapping. '%(describe[:options])':: human-readable name, like
Documentation/pretty-formats.txt | 4 ++++ pretty.c | 3 +++ t/t4205-log-pretty-formats.sh | 6 ++++++ 3 files changed, 13 insertions(+)
Documentation/pretty-formats.txt +4 -0
@@ -190,6 +190,8 @@ The placeholders are: '%ai':: author date, ISO 8601-like format '%aI':: author date, strict ISO 8601 format '%as':: author date, short format (`YYYY-MM-DD`) +'%ah':: author date, human style (like the --date=human option of + linkgit:rev-list-options.txt[1]) '%cn':: committer name '%cN':: committer name (respecting .mailmap, see linkgit:git-shortlog[1] or linkgit:git-blame[1])
@@ -206,6 +208,8 @@ The placeholders are: '%ci':: committer date, ISO 8601-like format '%cI':: committer date, strict ISO 8601 format '%cs':: committer date, short format (`YYYY-MM-DD`) +'%ch':: committer date, human style(like the --date=human option of + linkgit:rev-list-options.txt[1]) '%d':: ref names, like the --decorate option of linkgit:git-log[1] '%D':: ref names without the " (", ")" wrapping. '%(describe[:options])':: human-readable name, like
pretty.c +3 -0
@@ -745,6 +745,9 @@ static size_t format_person_part(struct strbuf *sb, char part,case 'I' :/* date, ISO 8601 strict */ strbuf_addstr (sb,show_ident_date (&s,DATE_MODE (ISO8601_STRICT )));return placeholder_len; +case 'h' :/* date, human */ +strbuf_addstr (sb,show_ident_date (&s,DATE_MODE (HUMAN ))); +return placeholder_len;case 's' :strbuf_addstr (sb,show_ident_date (&s,DATE_MODE (SHORT )));return placeholder_len;
t/t4205-log-pretty-formats.sh +6 -0
@@ -539,6 +539,12 @@ test_expect_success 'short date' ' test_cmp expected actual ' +test_expect_success 'human date' ' + git log --format=%ad%n%cd --date=human >expected && + git log --format=%ah%n%ch >actual && + test_cmp expected actual +' + # get new digests (with no abbreviations) test_expect_success 'set up log decoration tests' ' head1=$(git rev-parse --verify HEAD~0) &&
base-commit: b0c09ab8796fb736efa432b8e817334f3e5ee75a
Signature · 1 line
gitgitgadget
quoting nit..
Quoted 59 lines · ZheNing Hu via GitGitGadget
From: ZheNing Hu <[email protected]>
Add the placeholders %ah and %ch to format author date and committer date, like --date=human does, which provides more humanity date output.
Signed-off-by ZheNing Hu <[email protected]>---
[GSOC] pretty: provide human date formatReasons for making this patch: --date=human has no corresponding --pretty option.
Although --date=human with --pretty="%(a|c)d" can achieve the same effect with --pretty="%(a|c)h", but it can be noticed that most time formats implement the corresponding option of --pretty, such as --date=iso8601 can be replaced by --pretty=%(a|c)i, so add "--pretty=%(a|c)h" seems to be a very reasonable thing.
Change from v1: add %(a|c)h link to rev-list-options.txt.
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-939%2Fadlternative%2Fpretty_human-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-939/adlternative/pretty_human-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/939Range-diff vs v1:
1:
ed8abd6179d1! 1:1517708876b5[GSOC] pretty: provide human date format
@@Documentation/pretty-formats.txt: The placeholders are:
'%ai':: author date, ISO 8601-like format
'%aI':: author date, strict ISO 8601 format
'%as':: author date, short format (YYYY-MM-DD)
-+'%ah':: author date, human style
++'%ah':: author date, human style (like the --date=human option of
++ linkgit:rev-list-options.txt[1])
'%cn':: committer name
'%cN':: committer name (respecting .mailmap, see
linkgit:git-shortlog[1] or linkgit:git-blame[1])
@@Documentation/pretty-formats.txt: The placeholders are:
'%ci':: committer date, ISO 8601-like format
'%cI':: committer date, strict ISO 8601 format
'%cs':: committer date, short format (YYYY-MM-DD)
-+'%ch':: committer date, human style
++'%ch':: committer date, human style(like the --date=human option of
++ linkgit:rev-list-options.txt[1])
'%d':: ref names, like the --decorate option of linkgit:git-log[1] '%D':: ref names without the " (", ")" wrapping. '%(describe[:options])':: human-readable name, likeDocumentation/pretty-formats.txt | 4 ++++ pretty.c | 3 +++ t/t4205-log-pretty-formats.sh | 6 ++++++ 3 files changed, 13 insertions(+)Documentation/pretty-formats.txt +0
-0
Documentation/pretty-formats.txt The placeholders are: · line 193
Quoted 4 lines
Documentation/pretty-formats.txt +1
-0@@ -190,6 +190,8 @@ The placeholders are: '%ai':: author date, ISO 8601-like format '%aI':: author date, strict ISO 8601 format '%as':: author date, short format (`YYYY-MM-DD`) +'%ah':: author date, human style (like the --date=human option of
shouldn't that option be quoted " --date=human " so as to match the format in rev-list?
Documentation/pretty-formats.txt The placeholders are: · line 194
Quoted 1 line
Documentation/pretty-formats.txt +1
-0+ linkgit:rev-list-options.txt[1])
Also. Is this right? Shouldn't it just link to the dashed git- command's man page, rather than the file, i.e. linkgit:git-rev-list[1])
Documentation/pretty-formats.txt The placeholders are: · line 211
Quoted 8 lines
Documentation/pretty-formats.txt +1
-0'%cn':: committer name '%cN':: committer name (respecting .mailmap, see linkgit:git-shortlog[1] or linkgit:git-blame[1])@@ -206,6 +208,8 @@ The placeholders are: '%ci':: committer date, ISO 8601-like format '%cI':: committer date, strict ISO 8601 format '%cs':: committer date, short format (`YYYY-MM-DD`) +'%ch':: committer date, human style(like the --date=human option of
likewise, quote the option ? and resolve the linkgit: to the man page
Quoted 36 lines
Documentation/pretty-formats.txt +1
-0+ linkgit:rev-list-options.txt[1]) '%d':: ref names, like the --decorate option of linkgit:git-log[1] '%D':: ref names without the " (", ")" wrapping. '%(describe[:options])':: human-readable name, likepretty.c +3
-0@@ -745,6 +745,9 @@ static size_t format_person_part(struct strbuf *sb, char part,case 'I' :/* date, ISO 8601 strict */ strbuf_addstr (sb,show_ident_date (&s,DATE_MODE (ISO8601_STRICT )));return placeholder_len; +case 'h' :/* date, human */ +strbuf_addstr (sb,show_ident_date (&s,DATE_MODE (HUMAN ))); +return placeholder_len;case 's' :strbuf_addstr (sb,show_ident_date (&s,DATE_MODE (SHORT )));return placeholder_len;t/t4205-log-pretty-formats.sh +6
-0@@ -539,6 +539,12 @@ test_expect_success 'short date' ' test_cmp expected actual ' +test_expect_success 'human date' ' + git log --format=%ad%n%cd --date=human >expected && + git log --format=%ah%n%ch >actual && + test_cmp expected actual +' + # get new digests (with no abbreviations) test_expect_success 'set up log decoration tests' ' head1=$(git rev-parse --verify HEAD~0) &&
Quoted 1 line
base-commit:
b0c09ab8796fb736efa432b8e817334f3e5ee75a
Looks good otherwise.
Philip
cover pretty tests: --date/format test improvements
In reply to ZheNing Hu via GitGitGadgetA couple of trivial changes noticed when reviewing the "pretty:
provide human date format" series.
Ævar Arnfjörð Bjarmason (2):
pretty tests: simplify %aI/%cI date format test pretty tests: give --date/format tests a better description
t/t4205-log-pretty-formats.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
Signature · 1 line
2.31.1.734.g8d26f61af32
PATCH 1/2 pretty tests: simplify %aI/%cI date format test
Change a needlessly complex test for the %aI/%cI date formats (iso-strict) added in 466fb6742d7 (pretty: provide a strict ISO 8601 date format, 2014-08-29) to instead use the same pattern used to test %as/%cs since 0df621172d8 (pretty: provide short date format, 2019-11-19).
--- t/t4205-log-pretty-formats.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
t/t4205-log-pretty-formats.sh +1 -2
@@ -527,8 +527,7 @@ test_expect_success 'strbuf_utf8_replace() not producing NUL' ' # ISO strict date format test_expect_success 'ISO and ISO-strict date formats display the same values' ' - git log --format=%ai%n%ci | - sed -e "s/ /T/; s/ //; s/..\$/:&/" >expected && + git log --format=%ad%n%cd --date=iso-strict >expected && git log --format=%aI%n%cI >actual && test_cmp expected actual '
Signature · 1 line
2.31.1.734.g8d26f61af32
Re: [PATCH 1/2] pretty tests: simplify %aI/%cI date format test
Quoted 16 lines · Ævar Arnfjörð Bjarmason
Change a needlessly complex test for the %aI/%cI date formats (iso-strict) added in
466fb6742d7(pretty: provide a strict ISO 8601 date format, 2014-08-29) to instead use the same pattern used to test %as/%cs since0df621172d8(pretty: provide short date format, 2019-11-19).Signed-off-by Ævar Arnfjörð Bjarmason <[email protected]>--- t/t4205-log-pretty-formats.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)t/t4205-log-pretty-formats.sh +0
-0
t/t4205-log-pretty-formats.sh test_expect_success 'strbuf_utf8_replace() not producing NUL' ' · line 533
Quoted 9 lines
t/t4205-log-pretty-formats.sh +1
-2@@ -527,8 +527,7 @@ test_expect_success 'strbuf_utf8_replace() not producing NUL' ' # ISO strict date format test_expect_success 'ISO and ISO-strict date formats display the same values' ' - git log --format=%ai%n%ci | - sed -e "s/ /T/; s/ //; s/..\$/:&/" >expected && + git log --format=%ad%n%cd --date=iso-strict >expected && git log --format=%aI%n%cI >actual && test_cmp expected actual '
LGTM.
I wonder if these format shortcut tests that now look so regular should be put into a loop with a few suitable loop parameters?
Cheers, Beat
Re: [PATCH 1/2] pretty tests: simplify %aI/%cI date format test
In reply to Ævar Arnfjörð Bjarmasont/t4205-log-pretty-formats.sh test_expect_success 'strbuf_utf8_replace() not producing NUL' ' · line 531
Quoted 6 lines · Ævar Arnfjörð Bjarmason
# ISO strict date format
test_expect_success'ISO and ISO-strict date formats display the same values' 't/t4205-log-pretty-formats.sh +1
-2- git log --format=%ai%n%ci | - sed -e "s/ /T/; s/ //; s/..\$/:&/" >expected && + git log --format=%ad%n%cd --date=iso-strict >expected && git log --format=%aI%n%cI >actual &&
While these two must show the same output, I wonder how much value we are getting out of them. Don't they end up exercising pretty much the same codepath?
Not that I think the original is any better at all, though ;-)
Quoted 2 lines
test_cmpexpected actual
'
PATCH 2/2 pretty tests: give --date/format tests a better description
In reply to Ævar Arnfjörð BjarmasonChange the description for the --date/format equivalency tests added in 466fb6742d7 (pretty: provide a strict ISO 8601 date format, 2014-08-29) and 0df621172d8 (pretty: provide short date format, 2019-11-19) to be more meaningful.
This allows us to reword the comment added in the former commit to refer to both tests, and any other future test, such as the in-flight --date=human format being proposed in [1].
1. http://lore.kernel.org/git/[email protected]
--- t/t4205-log-pretty-formats.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
t/t4205-log-pretty-formats.sh +3 -3
@@ -525,14 +525,14 @@ test_expect_success 'strbuf_utf8_replace() not producing NUL' ' ! grep Q actual ' -# ISO strict date format -test_expect_success 'ISO and ISO-strict date formats display the same values' ' +# --date=[XXX] and corresponding %a[X] %c[X] format equivalency +test_expect_success '--date=iso-strict %ad%cd is the same as %aI%cI' ' git log --format=%ad%n%cd --date=iso-strict >expected && git log --format=%aI%n%cI >actual && test_cmp expected actual ' -test_expect_success 'short date' ' +test_expect_success '--date=short %ad%cd is the same as %as%cs' ' git log --format=%ad%n%cd --date=short >expected && git log --format=%as%n%cs >actual && test_cmp expected actual
Signature · 1 line
2.31.1.734.g8d26f61af32
Re: [PATCH 2/2] pretty tests: give --date/format tests a better description
Hi, Ævar Arnfjörð Bjarmason,
Quoted 40 lines · Ævar Arnfjörð Bjarmason <[email protected]> 于2021年4月25日周日 下午5:11写道:
Change the description for the --date/format equivalency tests added in
466fb6742d7(pretty: provide a strict ISO 8601 date format, 2014-08-29) and0df621172d8(pretty: provide short date format, 2019-11-19) to be more meaningful.This allows us to reword the comment added in the former commit to refer to both tests, and any other future test, such as the in-flight --date=human format being proposed in [1].
1. http://lore.kernel.org/git/[email protected]
Signed-off-by Ævar Arnfjörð Bjarmason <[email protected]>--- t/t4205-log-pretty-formats.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)t/t4205-log-pretty-formats.sh +3
-4@@ -525,14 +525,14 @@ test_expect_success 'strbuf_utf8_replace() not producing NUL' ' ! grep Q actual ' -# ISO strict date format -test_expect_success 'ISO and ISO-strict date formats display the same values' ' +# --date=[XXX] and corresponding %a[X] %c[X] format equivalency +test_expect_success '--date=iso-strict %ad%cd is the same as %aI%cI' ' git log --format=%ad%n%cd --date=iso-strict >expected && git log --format=%aI%n%cI >actual && test_cmp expected actual ' -test_expect_success 'short date' ' +test_expect_success '--date=short %ad%cd is the same as %as%cs' ' git log --format=%ad%n%cd --date=short >expected && git log --format=%as%n%cs >actual && test_cmp expected actual --
Quoted 2 lines
2.31.1.734.g8d26f61af32
Notice that you modified the title of the testshort date---> --date=short %ad%cd is the same as %as%cs, then the human date patch I am working should also do the similar things as you do here?
--
ZheNing Hu
PATCH v3 1/1 pretty: provide human date format
In reply to ZheNing Hu via GitGitGadgetFrom: ZheNing Hu <[email protected]>
Add the placeholders %ah and %ch to format author date and committer date, like --date=human does, which provides more humanity date output.
---
[GSOC] pretty: provide human date format
Reasons for making this patch: --date=human has no corresponding --pretty option.
Although --date=human with --pretty="%(a|c)d" can achieve the same effect with --pretty="%(a|c)h", but it can be noticed that most time formats implement the corresponding option of --pretty, such as --date=iso8601 can be replaced by --pretty=%(a|c)i, so add --pretty=%(a|c)h seems to be a very reasonable thing.
Change from v2: change %(a|c)h link to git-rev-list and change to more suitable test title.
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-939%2Fadlternative%2Fpretty_human-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-939/adlternative/pretty_human-v3
Pull-Request: https://github.com/gitgitgadget/git/pull/939
Range-diff vs v2:
1: 1517708876b5 ! 1: 67c57d8f4a17 [GSOC] pretty: provide human date format
@@ Documentation/pretty-formats.txt: The placeholders are:
'%ai':: author date, ISO 8601-like format
'%aI':: author date, strict ISO 8601 format
'%as':: author date, short format (YYYY-MM-DD)
-+'%ah':: author date, human style (like the --date=human option of
-+ linkgit:rev-list-options.txt[1])
++'%ah':: author date, human style (like the --date=human option of
++ linkgit:git-rev-list[1])
'%cn':: committer name
'%cN':: committer name (respecting .mailmap, see
linkgit:git-shortlog[1] or linkgit:git-blame[1])
@@ Documentation/pretty-formats.txt: The placeholders are:
'%ci':: committer date, ISO 8601-like format
'%cI':: committer date, strict ISO 8601 format
'%cs':: committer date, short format (YYYY-MM-DD)
-+'%ch':: committer date, human style(like the --date=human option of
-+ linkgit:rev-list-options.txt[1])
++'%ch':: committer date, human style(like the --date=human option of
++ linkgit:git-rev-list[1])
'%d':: ref names, like the --decorate option of linkgit:git-log[1] '%D':: ref names without the " (", ")" wrapping. '%(describe[:options])':: human-readable name, like
@@ t/t4205-log-pretty-formats.sh: test_expect_success 'short date' '
test_cmp expected actual
'
-+test_expect_success 'human date' ' ++test_expect_success '--date=human %ad%cd is the same as %ah%ch' '
+ git log --format=%ad%n%cd --date=human >expected &&
+ git log --format=%ah%n%ch >actual &&
+ test_cmp expected actual
Documentation/pretty-formats.txt | 4 ++++ pretty.c | 3 +++ t/t4205-log-pretty-formats.sh | 6 ++++++ 3 files changed, 13 insertions(+)
Documentation/pretty-formats.txt +4 -0
@@ -190,6 +190,8 @@ The placeholders are: '%ai':: author date, ISO 8601-like format '%aI':: author date, strict ISO 8601 format '%as':: author date, short format (`YYYY-MM-DD`) +'%ah':: author date, human style (like the `--date=human` option of + linkgit:git-rev-list[1]) '%cn':: committer name '%cN':: committer name (respecting .mailmap, see linkgit:git-shortlog[1] or linkgit:git-blame[1])
@@ -206,6 +208,8 @@ The placeholders are: '%ci':: committer date, ISO 8601-like format '%cI':: committer date, strict ISO 8601 format '%cs':: committer date, short format (`YYYY-MM-DD`) +'%ch':: committer date, human style(like the `--date=human` option of + linkgit:git-rev-list[1]) '%d':: ref names, like the --decorate option of linkgit:git-log[1] '%D':: ref names without the " (", ")" wrapping. '%(describe[:options])':: human-readable name, like
pretty.c +3 -0
@@ -745,6 +745,9 @@ static size_t format_person_part(struct strbuf *sb, char part,case 'I' :/* date, ISO 8601 strict */ strbuf_addstr (sb,show_ident_date (&s,DATE_MODE (ISO8601_STRICT )));return placeholder_len; +case 'h' :/* date, human */ +strbuf_addstr (sb,show_ident_date (&s,DATE_MODE (HUMAN ))); +return placeholder_len;case 's' :strbuf_addstr (sb,show_ident_date (&s,DATE_MODE (SHORT )));return placeholder_len;
t/t4205-log-pretty-formats.sh +6 -0
@@ -539,6 +539,12 @@ test_expect_success 'short date' ' test_cmp expected actual ' +test_expect_success '--date=human %ad%cd is the same as %ah%ch' ' + git log --format=%ad%n%cd --date=human >expected && + git log --format=%ah%n%ch >actual && + test_cmp expected actual +' + # get new digests (with no abbreviations) test_expect_success 'set up log decoration tests' ' head1=$(git rev-parse --verify HEAD~0) &&
base-commit: b0c09ab8796fb736efa432b8e817334f3e5ee75a
Signature · 1 line
gitgitgadget
PATCH v4 1/1 pretty: provide human date format
From: ZheNing Hu <[email protected]>
Add the placeholders %ah and %ch to format author date and committer date, like --date=human does, which provides more humanity date output.
---
[GSOC] pretty: provide human date format
Reasons for making this patch: --date=human has no corresponding --pretty option.
Although --date=human with --pretty="%(a|c)d" can achieve the same effect with --pretty="%(a|c)h", but it can be noticed that most time formats implement the corresponding option of --pretty, such as --date=iso8601 can be replaced by --pretty=%(a|c)i, so add --pretty=%(a|c)h seems to be a very reasonable thing.
Change from v3: Fix format errors.
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-939%2Fadlternative%2Fpretty_human-v4
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-939/adlternative/pretty_human-v4
Pull-Request: https://github.com/gitgitgadget/git/pull/939
Range-diff vs v3:
1: 67c57d8f4a17 ! 1: 8e5ae0d9a01e [GSOC] pretty: provide human date format
@@ Documentation/pretty-formats.txt: The placeholders are:
'%ci':: committer date, ISO 8601-like format
'%cI':: committer date, strict ISO 8601 format
'%cs':: committer date, short format (YYYY-MM-DD)
-+'%ch':: committer date, human style(like the --date=human option of ++'%ch':: committer date, human style (like the --date=human option of
+ linkgit:git-rev-list[1])
'%d':: ref names, like the --decorate option of linkgit:git-log[1] '%D':: ref names without the " (", ")" wrapping.
Documentation/pretty-formats.txt | 4 ++++ pretty.c | 3 +++ t/t4205-log-pretty-formats.sh | 6 ++++++ 3 files changed, 13 insertions(+)
Documentation/pretty-formats.txt +4 -0
@@ -190,6 +190,8 @@ The placeholders are: '%ai':: author date, ISO 8601-like format '%aI':: author date, strict ISO 8601 format '%as':: author date, short format (`YYYY-MM-DD`) +'%ah':: author date, human style (like the `--date=human` option of + linkgit:git-rev-list[1]) '%cn':: committer name '%cN':: committer name (respecting .mailmap, see linkgit:git-shortlog[1] or linkgit:git-blame[1])
@@ -206,6 +208,8 @@ The placeholders are: '%ci':: committer date, ISO 8601-like format '%cI':: committer date, strict ISO 8601 format '%cs':: committer date, short format (`YYYY-MM-DD`) +'%ch':: committer date, human style (like the `--date=human` option of + linkgit:git-rev-list[1]) '%d':: ref names, like the --decorate option of linkgit:git-log[1] '%D':: ref names without the " (", ")" wrapping. '%(describe[:options])':: human-readable name, like
pretty.c +3 -0
@@ -745,6 +745,9 @@ static size_t format_person_part(struct strbuf *sb, char part,case 'I' :/* date, ISO 8601 strict */ strbuf_addstr (sb,show_ident_date (&s,DATE_MODE (ISO8601_STRICT )));return placeholder_len; +case 'h' :/* date, human */ +strbuf_addstr (sb,show_ident_date (&s,DATE_MODE (HUMAN ))); +return placeholder_len;case 's' :strbuf_addstr (sb,show_ident_date (&s,DATE_MODE (SHORT )));return placeholder_len;
t/t4205-log-pretty-formats.sh +6 -0
@@ -539,6 +539,12 @@ test_expect_success 'short date' ' test_cmp expected actual ' +test_expect_success '--date=human %ad%cd is the same as %ah%ch' ' + git log --format=%ad%n%cd --date=human >expected && + git log --format=%ah%n%ch >actual && + test_cmp expected actual +' + # get new digests (with no abbreviations) test_expect_success 'set up log decoration tests' ' head1=$(git rev-parse --verify HEAD~0) &&
base-commit: b0c09ab8796fb736efa432b8e817334f3e5ee75a
Signature · 1 line
gitgitgadget