All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [GSOC] pretty: provide human date format
@ 2021-04-23 16:27 ZheNing Hu via GitGitGadget
  2021-04-23 20:21 ` Taylor Blau
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: ZheNing Hu via GitGitGadget @ 2021-04-23 16:27 UTC (permalink / raw)
  To: git
  Cc: René Scharfe, Junio C Hamano, Linus Torvalds, ZheNing Hu,
	ZheNing Hu

From: ZheNing Hu <adlternative@gmail.com>

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 <adlternative@gmail.com>
---
    [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(+)

diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt
index 45133066e412..9cdcdb8bb414 100644
--- a/Documentation/pretty-formats.txt
+++ b/Documentation/pretty-formats.txt
@@ -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
diff --git a/pretty.c b/pretty.c
index e5b33ba034bd..b1ecd039cef2 100644
--- a/pretty.c
+++ b/pretty.c
@@ -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;
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index cabdf7d57a00..d4d75b0b350e 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -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
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH] [GSOC] pretty: provide human date format
  2021-04-23 16:27 [PATCH] [GSOC] pretty: provide human date format ZheNing Hu via GitGitGadget
@ 2021-04-23 20:21 ` Taylor Blau
  2021-04-24 13:26   ` ZheNing Hu
  2021-04-23 21:10 ` Philip Oakley
  2021-04-24 14:42 ` [PATCH v2] " ZheNing Hu via GitGitGadget
  2 siblings, 1 reply; 15+ messages in thread
From: Taylor Blau @ 2021-04-23 20:21 UTC (permalink / raw)
  To: ZheNing Hu via GitGitGadget
  Cc: git, René Scharfe, Junio C Hamano, Linus Torvalds, ZheNing Hu

Hi ZheNing,

On Fri, Apr 23, 2021 at 04:27:25PM +0000, ZheNing Hu via GitGitGadget wrote:
> From: ZheNing Hu <adlternative@gmail.com>
>
> 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.

> Signed-off-by: ZheNing Hu <adlternative@gmail.com>
> ---
>     [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.

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".

> 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(+)
>
> diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt
> index 45133066e412..9cdcdb8bb414 100644
> --- a/Documentation/pretty-formats.txt
> +++ b/Documentation/pretty-formats.txt
> @@ -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.

>  '%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.

  Reviewed-by: Taylor Blau <me@ttaylorr.com>

Thanks,
Taylor

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] [GSOC] pretty: provide human date format
  2021-04-23 16:27 [PATCH] [GSOC] pretty: provide human date format ZheNing Hu via GitGitGadget
  2021-04-23 20:21 ` Taylor Blau
@ 2021-04-23 21:10 ` Philip Oakley
  2021-04-24 13:33   ` ZheNing Hu
  2021-04-24 14:42 ` [PATCH v2] " ZheNing Hu via GitGitGadget
  2 siblings, 1 reply; 15+ messages in thread
From: Philip Oakley @ 2021-04-23 21:10 UTC (permalink / raw)
  To: ZheNing Hu via GitGitGadget, git
  Cc: René Scharfe, Junio C Hamano, Linus Torvalds, ZheNing Hu

On 23/04/2021 17:27, ZheNing Hu via GitGitGadget wrote:
> From: ZheNing Hu <adlternative@gmail.com>
>
> 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 <adlternative@gmail.com>
> ---
>     [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(+)
>
> diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt
> index 45133066e412..9cdcdb8bb414 100644
> --- a/Documentation/pretty-formats.txt
> +++ b/Documentation/pretty-formats.txt
> @@ -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.

>  '%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.
>  '%d':: ref names, like the --decorate option of linkgit:git-log[1]
>  '%D':: ref names without the " (", ")" wrapping.
>  '%(describe[:options])':: human-readable name, like
> diff --git a/pretty.c b/pretty.c
> index e5b33ba034bd..b1ecd039cef2 100644
> --- a/pretty.c
> +++ b/pretty.c
> @@ -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;
> diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
> index cabdf7d57a00..d4d75b0b350e 100755
> --- a/t/t4205-log-pretty-formats.sh
> +++ b/t/t4205-log-pretty-formats.sh
> @@ -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
--
Philip

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] [GSOC] pretty: provide human date format
  2021-04-23 20:21 ` Taylor Blau
@ 2021-04-24 13:26   ` ZheNing Hu
  0 siblings, 0 replies; 15+ messages in thread
From: ZheNing Hu @ 2021-04-24 13:26 UTC (permalink / raw)
  To: Taylor Blau
  Cc: ZheNing Hu via GitGitGadget, Git List, René Scharfe,
	Junio C Hamano, Linus Torvalds

Taylor Blau <me@ttaylorr.com> 于2021年4月24日周六 上午4:21写道:
>
> Hi ZheNing,
>
> On Fri, Apr 23, 2021 at 04:27:25PM +0000, ZheNing Hu via GitGitGadget wrote:
> > From: ZheNing Hu <adlternative@gmail.com>
> >
> > 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.
>

Yes, I saw René Scharfe's (have --cc) patch and learned handle way from it.

> > Signed-off-by: ZheNing Hu <adlternative@gmail.com>
> > ---
> >     [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.
>
> 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.

> > 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(+)
> >
> > diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt
> > index 45133066e412..9cdcdb8bb414 100644
> > --- a/Documentation/pretty-formats.txt
> > +++ b/Documentation/pretty-formats.txt
> > @@ -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.
>
> >  '%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.
>
>   Reviewed-by: Taylor Blau <me@ttaylorr.com>
>
> Thanks,
> Taylor

Thanks!
--
ZheNing Hu

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] [GSOC] pretty: provide human date format
  2021-04-23 21:10 ` Philip Oakley
@ 2021-04-24 13:33   ` ZheNing Hu
  0 siblings, 0 replies; 15+ messages in thread
From: ZheNing Hu @ 2021-04-24 13:33 UTC (permalink / raw)
  To: philipoakley
  Cc: ZheNing Hu via GitGitGadget, Git List, René Scharfe,
	Junio C Hamano, Linus Torvalds

Philip Oakley <philipoakley@iee.email> 于2021年4月24日周六 上午5:10写道:
>
> On 23/04/2021 17:27, ZheNing Hu via GitGitGadget wrote:
> > From: ZheNing Hu <adlternative@gmail.com>
> >
> > 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 <adlternative@gmail.com>
> > ---
> >     [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(+)
> >
> > diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt
> > index 45133066e412..9cdcdb8bb414 100644
> > --- a/Documentation/pretty-formats.txt
> > +++ b/Documentation/pretty-formats.txt
> > @@ -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.
>

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.

> >  '%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.
> >  '%d':: ref names, like the --decorate option of linkgit:git-log[1]
> >  '%D':: ref names without the " (", ")" wrapping.
> >  '%(describe[:options])':: human-readable name, like
> > diff --git a/pretty.c b/pretty.c
> > index e5b33ba034bd..b1ecd039cef2 100644
> > --- a/pretty.c
> > +++ b/pretty.c
> > @@ -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;
> > diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
> > index cabdf7d57a00..d4d75b0b350e 100755
> > --- a/t/t4205-log-pretty-formats.sh
> > +++ b/t/t4205-log-pretty-formats.sh
> > @@ -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
> --
> Philip

Thanks!
--
ZheNing Hu

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH v2] [GSOC] pretty: provide human date format
  2021-04-23 16:27 [PATCH] [GSOC] pretty: provide human date format ZheNing Hu via GitGitGadget
  2021-04-23 20:21 ` Taylor Blau
  2021-04-23 21:10 ` Philip Oakley
@ 2021-04-24 14:42 ` ZheNing Hu via GitGitGadget
  2021-04-24 19:44   ` Philip Oakley
                     ` (2 more replies)
  2 siblings, 3 replies; 15+ messages in thread
From: ZheNing Hu via GitGitGadget @ 2021-04-24 14:42 UTC (permalink / raw)
  To: git
  Cc: René Scharfe, Junio C Hamano, Linus Torvalds, Taylor Blau,
	Philip Oakley, ZheNing Hu, ZheNing Hu

From: ZheNing Hu <adlternative@gmail.com>

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 <adlternative@gmail.com>
---
    [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(+)

diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt
index 45133066e412..e37d5cbb6b16 100644
--- a/Documentation/pretty-formats.txt
+++ b/Documentation/pretty-formats.txt
@@ -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
diff --git a/pretty.c b/pretty.c
index e5b33ba034bd..b1ecd039cef2 100644
--- a/pretty.c
+++ b/pretty.c
@@ -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;
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index cabdf7d57a00..d4d75b0b350e 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -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
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH v2] [GSOC] pretty: provide human date format
  2021-04-24 14:42 ` [PATCH v2] " ZheNing Hu via GitGitGadget
@ 2021-04-24 19:44   ` Philip Oakley
  2021-04-25  9:11   ` [PATCH 0/2] pretty tests: --date/format test improvements Ævar Arnfjörð Bjarmason
  2021-04-25 10:41   ` [PATCH v3] [GSOC] pretty: provide human date format ZheNing Hu via GitGitGadget
  2 siblings, 0 replies; 15+ messages in thread
From: Philip Oakley @ 2021-04-24 19:44 UTC (permalink / raw)
  To: ZheNing Hu via GitGitGadget, git
  Cc: René Scharfe, Junio C Hamano, Linus Torvalds, Taylor Blau,
	ZheNing Hu

quoting nit..
On 24/04/2021 15:42, ZheNing Hu via GitGitGadget wrote:
> From: ZheNing Hu <adlternative@gmail.com>
>
> 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 <adlternative@gmail.com>
> ---
>     [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(+)
>
> diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt
> index 45133066e412..e37d5cbb6b16 100644
> --- a/Documentation/pretty-formats.txt
> +++ b/Documentation/pretty-formats.txt
> @@ -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?
> +	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])
>  '%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
> +	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
> diff --git a/pretty.c b/pretty.c
> index e5b33ba034bd..b1ecd039cef2 100644
> --- a/pretty.c
> +++ b/pretty.c
> @@ -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;
> diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
> index cabdf7d57a00..d4d75b0b350e 100755
> --- a/t/t4205-log-pretty-formats.sh
> +++ b/t/t4205-log-pretty-formats.sh
> @@ -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
Looks good otherwise.
Philip

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 0/2] pretty tests: --date/format test improvements
  2021-04-24 14:42 ` [PATCH v2] " ZheNing Hu via GitGitGadget
  2021-04-24 19:44   ` Philip Oakley
@ 2021-04-25  9:11   ` Ævar Arnfjörð Bjarmason
  2021-04-25  9:11     ` [PATCH 1/2] pretty tests: simplify %aI/%cI date format test Ævar Arnfjörð Bjarmason
  2021-04-25  9:11     ` [PATCH 2/2] pretty tests: give --date/format tests a better description Ævar Arnfjörð Bjarmason
  2021-04-25 10:41   ` [PATCH v3] [GSOC] pretty: provide human date format ZheNing Hu via GitGitGadget
  2 siblings, 2 replies; 15+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-04-25  9:11 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, ZheNing Hu, René Scharfe, Taylor Blau,
	Beat Bolli, Ævar Arnfjörð Bjarmason

A 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(-)

-- 
2.31.1.734.g8d26f61af32


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 1/2] pretty tests: simplify %aI/%cI date format test
  2021-04-25  9:11   ` [PATCH 0/2] pretty tests: --date/format test improvements Ævar Arnfjörð Bjarmason
@ 2021-04-25  9:11     ` Ævar Arnfjörð Bjarmason
  2021-04-26 21:22       ` Beat Bolli
  2021-04-27  7:08       ` Junio C Hamano
  2021-04-25  9:11     ` [PATCH 2/2] pretty tests: give --date/format tests a better description Ævar Arnfjörð Bjarmason
  1 sibling, 2 replies; 15+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-04-25  9:11 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, ZheNing Hu, René Scharfe, Taylor Blau,
	Beat Bolli, Æ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 since 0df621172d8 (pretty: provide short date format,
2019-11-19).

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/t4205-log-pretty-formats.sh | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index cabdf7d57a0..0462115ac5c 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -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
 '
-- 
2.31.1.734.g8d26f61af32


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 2/2] pretty tests: give --date/format tests a better description
  2021-04-25  9:11   ` [PATCH 0/2] pretty tests: --date/format test improvements Ævar Arnfjörð Bjarmason
  2021-04-25  9:11     ` [PATCH 1/2] pretty tests: simplify %aI/%cI date format test Ævar Arnfjörð Bjarmason
@ 2021-04-25  9:11     ` Ævar Arnfjörð Bjarmason
  2021-04-25  9:30       ` ZheNing Hu
  1 sibling, 1 reply; 15+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-04-25  9:11 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, ZheNing Hu, René Scharfe, Taylor Blau,
	Beat Bolli, Ævar Arnfjörð Bjarmason

Change 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/pull.939.v2.git.1619275340051.gitgitgadget@gmail.com

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/t4205-log-pretty-formats.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 0462115ac5c..bcb558ef4d7 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -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
-- 
2.31.1.734.g8d26f61af32


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH 2/2] pretty tests: give --date/format tests a better description
  2021-04-25  9:11     ` [PATCH 2/2] pretty tests: give --date/format tests a better description Ævar Arnfjörð Bjarmason
@ 2021-04-25  9:30       ` ZheNing Hu
  0 siblings, 0 replies; 15+ messages in thread
From: ZheNing Hu @ 2021-04-25  9:30 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: Git List, Junio C Hamano, René Scharfe, Taylor Blau, Beat Bolli

Hi, Ævar Arnfjörð Bjarmason,

Ævar Arnfjörð Bjarmason <avarab@gmail.com> 于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) 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/pull.939.v2.git.1619275340051.gitgitgadget@gmail.com
>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
>  t/t4205-log-pretty-formats.sh | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
> index 0462115ac5c..bcb558ef4d7 100755
> --- a/t/t4205-log-pretty-formats.sh
> +++ b/t/t4205-log-pretty-formats.sh
> @@ -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
> --
> 2.31.1.734.g8d26f61af32
>

Notice that you modified the title of the test
`short 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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH v3] [GSOC] pretty: provide human date format
  2021-04-24 14:42 ` [PATCH v2] " ZheNing Hu via GitGitGadget
  2021-04-24 19:44   ` Philip Oakley
  2021-04-25  9:11   ` [PATCH 0/2] pretty tests: --date/format test improvements Ævar Arnfjörð Bjarmason
@ 2021-04-25 10:41   ` ZheNing Hu via GitGitGadget
  2021-05-03 15:37     ` [PATCH v4] " ZheNing Hu via GitGitGadget
  2 siblings, 1 reply; 15+ messages in thread
From: ZheNing Hu via GitGitGadget @ 2021-04-25 10:41 UTC (permalink / raw)
  To: git
  Cc: René Scharfe, Junio C Hamano, Linus Torvalds, Taylor Blau,
	Philip Oakley, Ævar Arnfjörð Bjarmason,
	ZheNing Hu, ZheNing Hu

From: ZheNing Hu <adlternative@gmail.com>

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 <adlternative@gmail.com>
---
    [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(+)

diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt
index 45133066e412..cd697f508c53 100644
--- a/Documentation/pretty-formats.txt
+++ b/Documentation/pretty-formats.txt
@@ -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
diff --git a/pretty.c b/pretty.c
index e5b33ba034bd..b1ecd039cef2 100644
--- a/pretty.c
+++ b/pretty.c
@@ -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;
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index cabdf7d57a00..10d511ba7307 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -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
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH 1/2] pretty tests: simplify %aI/%cI date format test
  2021-04-25  9:11     ` [PATCH 1/2] pretty tests: simplify %aI/%cI date format test Ævar Arnfjörð Bjarmason
@ 2021-04-26 21:22       ` Beat Bolli
  2021-04-27  7:08       ` Junio C Hamano
  1 sibling, 0 replies; 15+ messages in thread
From: Beat Bolli @ 2021-04-26 21:22 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason, git
  Cc: Junio C Hamano, ZheNing Hu, René Scharfe, Taylor Blau, Beat Bolli

On 25.04.21 11:11, Ævar Arnfjörð Bjarmason wrote:
> 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).
> 
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
>  t/t4205-log-pretty-formats.sh | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
> index cabdf7d57a0..0462115ac5c 100755
> --- a/t/t4205-log-pretty-formats.sh
> +++ b/t/t4205-log-pretty-formats.sh
> @@ -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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 1/2] pretty tests: simplify %aI/%cI date format test
  2021-04-25  9:11     ` [PATCH 1/2] pretty tests: simplify %aI/%cI date format test Ævar Arnfjörð Bjarmason
  2021-04-26 21:22       ` Beat Bolli
@ 2021-04-27  7:08       ` Junio C Hamano
  1 sibling, 0 replies; 15+ messages in thread
From: Junio C Hamano @ 2021-04-27  7:08 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: git, ZheNing Hu, René Scharfe, Taylor Blau, Beat Bolli

Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:

>  # 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 &&

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 ;-)

>  	test_cmp expected actual
>  '

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH v4] [GSOC] pretty: provide human date format
  2021-04-25 10:41   ` [PATCH v3] [GSOC] pretty: provide human date format ZheNing Hu via GitGitGadget
@ 2021-05-03 15:37     ` ZheNing Hu via GitGitGadget
  0 siblings, 0 replies; 15+ messages in thread
From: ZheNing Hu via GitGitGadget @ 2021-05-03 15:37 UTC (permalink / raw)
  To: git
  Cc: René Scharfe, Junio C Hamano, Linus Torvalds, Taylor Blau,
	Philip Oakley, Ævar Arnfjörð Bjarmason,
	Beat Bolli, ZheNing Hu, ZheNing Hu

From: ZheNing Hu <adlternative@gmail.com>

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 <adlternative@gmail.com>
---
    [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(+)

diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt
index 45133066e412..58bb2795284d 100644
--- a/Documentation/pretty-formats.txt
+++ b/Documentation/pretty-formats.txt
@@ -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
diff --git a/pretty.c b/pretty.c
index e5b33ba034bd..b1ecd039cef2 100644
--- a/pretty.c
+++ b/pretty.c
@@ -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;
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index cabdf7d57a00..10d511ba7307 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -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
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2021-05-03 15:37 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-23 16:27 [PATCH] [GSOC] pretty: provide human date format ZheNing Hu via GitGitGadget
2021-04-23 20:21 ` Taylor Blau
2021-04-24 13:26   ` ZheNing Hu
2021-04-23 21:10 ` Philip Oakley
2021-04-24 13:33   ` ZheNing Hu
2021-04-24 14:42 ` [PATCH v2] " ZheNing Hu via GitGitGadget
2021-04-24 19:44   ` Philip Oakley
2021-04-25  9:11   ` [PATCH 0/2] pretty tests: --date/format test improvements Ævar Arnfjörð Bjarmason
2021-04-25  9:11     ` [PATCH 1/2] pretty tests: simplify %aI/%cI date format test Ævar Arnfjörð Bjarmason
2021-04-26 21:22       ` Beat Bolli
2021-04-27  7:08       ` Junio C Hamano
2021-04-25  9:11     ` [PATCH 2/2] pretty tests: give --date/format tests a better description Ævar Arnfjörð Bjarmason
2021-04-25  9:30       ` ZheNing Hu
2021-04-25 10:41   ` [PATCH v3] [GSOC] pretty: provide human date format ZheNing Hu via GitGitGadget
2021-05-03 15:37     ` [PATCH v4] " ZheNing Hu via GitGitGadget

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.