All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Taylor Blau <me@ttaylorr.com>
Cc: git@vger.kernel.org, jacob@initialcommit.io, gitster@pobox.com,
	avarab@gmail.com
Subject: Re: [PATCH v2 1/6] shortlog: accept `--date`-related options
Date: Fri, 21 Oct 2022 01:32:07 -0400	[thread overview]
Message-ID: <Y1Iu1x6dR6GwiA2Y@coredump.intra.peff.net> (raw)
In-Reply-To: <58baccbaa8612adae55f776ce10806809861270c.1666320509.git.me@ttaylorr.com>

On Thu, Oct 20, 2022 at 11:11:29PM -0400, Taylor Blau wrote:

> diff --git a/Documentation/git-shortlog.txt b/Documentation/git-shortlog.txt
> index f64e77047b..311c041c06 100644
> --- a/Documentation/git-shortlog.txt
> +++ b/Documentation/git-shortlog.txt
> @@ -47,6 +47,11 @@ OPTIONS
>  
>  	Each pretty-printed commit will be rewrapped before it is shown.
>  
> +--date=<format>::
> +	With a `--group=format:<format>`, show dates formatted
> +	according to the given date string. (See the `--date` options
> +	in the "COMMIT FORMATTING" section of linkgit:git-log[1].)

I like this much better than including the whole date-formats section.
Two nits:

  - s/options/option/ ? I guess you could say there are "options" for
    formatting the date, but with "--date" it seems like you'd mean the
    singular option.

  - Because "Commit Formatting" is a subsection in git-log(1), the
    manual will format it with title caps, not all-caps.

> diff --git a/builtin/shortlog.c b/builtin/shortlog.c
> index 7a1e1fe7c0..53c379a51d 100644
> --- a/builtin/shortlog.c
> +++ b/builtin/shortlog.c
> @@ -211,7 +211,7 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
>  	ctx.fmt = CMIT_FMT_USERFORMAT;
>  	ctx.abbrev = log->abbrev;
>  	ctx.print_email_subject = 1;
> -	ctx.date_mode.type = DATE_NORMAL;
> +	ctx.date_mode = log->date_mode;
>  	ctx.output_encoding = get_log_output_encoding();
>  
>  	if (!log->summary) {

After the discussion in the last round of whether that funky caller in
make_cover_letter() properly initialized the "struct shortlog", I
wondered briefly if this would do the right thing for that caller. And
it does, because DATE_NORMAL is intentionally set to "0" to allow for
zero-initializing (which is what shortlog_init does).

Not that it matters in practice, because that caller will not group by
nor format using a date, but I was curious if I had inadvertently
introduced a gotcha for future callers. But it is good.

> diff --git a/t/t4201-shortlog.sh b/t/t4201-shortlog.sh
> index 3095b1b2ff..7547da539d 100755
> --- a/t/t4201-shortlog.sh
> +++ b/t/t4201-shortlog.sh
> @@ -83,6 +83,13 @@ test_expect_success 'pretty format' '
>  	test_cmp expect log.predictable
>  '
>  
> +test_expect_success 'pretty format (with --date)' '
> +	sed "s/SUBJECT/2005-04-07 OBJECT_NAME/" expect.template >expect &&
> +	git shortlog --format="%ad %H" --date=short HEAD >log &&
> +	fuzz log >log.predictable &&
> +	test_cmp expect log.predictable
> +'

And this looks sensible. If you dropped "%H" then you wouldn't need to
fuzz, and are still testing the interesting part. But just following the
whole template/fuzz thing of the surrounding tests is reasonable.

-Peff

  reply	other threads:[~2022-10-21  5:32 UTC|newest]

Thread overview: 72+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-11  0:33 [PATCH 0/7] shortlog: introduce `--group=<format>` Taylor Blau
2022-10-11  0:34 ` [PATCH 1/7] Documentation: extract date-options.txt Taylor Blau
2022-10-11  0:54   ` Jeff King
2022-10-11  1:02     ` Taylor Blau
2022-10-11  0:34 ` [PATCH 2/7] shortlog: accept `--date`-related options Taylor Blau
2022-10-11  0:48   ` Jeff King
2022-10-11  1:14     ` Taylor Blau
2022-10-11  0:34 ` [PATCH 3/7] shortlog: extract `--group` fragment for translation Taylor Blau
2022-10-11 10:55   ` Ævar Arnfjörð Bjarmason
2022-10-11 13:24     ` Jeff King
2022-10-11  0:34 ` [PATCH 4/7] shortlog: support arbitrary commit format `--group`s Taylor Blau
2022-10-11  1:12   ` Jeff King
2022-10-11  1:24     ` Taylor Blau
2022-10-11  1:28       ` Taylor Blau
2022-10-11  2:03         ` Jeff King
2022-10-11  2:02       ` Jeff King
2022-10-21  2:39         ` Taylor Blau
2022-10-21  5:21           ` Jeff King
2022-10-21 22:12             ` Taylor Blau
2022-10-11  0:34 ` [PATCH 5/7] shortlog: implement `--group=author` in terms of `--group=<format>` Taylor Blau
2022-10-11  1:34   ` Jeff King
2022-10-11  1:48     ` Taylor Blau
2022-10-11  2:15       ` Jeff King
2022-10-21  2:03         ` Taylor Blau
2022-10-21  2:02       ` Taylor Blau
2022-10-21  5:03         ` Jeff King
2022-10-21 22:05           ` Taylor Blau
2022-10-11 10:57   ` Ævar Arnfjörð Bjarmason
2022-10-11 11:07     ` Ævar Arnfjörð Bjarmason
2022-10-11  0:34 ` [PATCH 6/7] shortlog: implement `--group=committer` " Taylor Blau
2022-10-11  1:35   ` Jeff King
2022-10-11  0:34 ` [PATCH 7/7] shortlog: implement `--group=trailer` " Taylor Blau
2022-10-11  1:50   ` Jeff King
2022-10-11  1:57     ` Jeff King
2022-10-21  1:38     ` Taylor Blau
2022-10-21  3:11 ` [PATCH v2 0/6] shortlog: introduce `--group=<format>` Taylor Blau
2022-10-21  3:11   ` [PATCH v2 1/6] shortlog: accept `--date`-related options Taylor Blau
2022-10-21  5:32     ` Jeff King [this message]
2022-10-21 21:55       ` Taylor Blau
2022-10-21  3:11   ` [PATCH v2 2/6] shortlog: make trailer insertion a noop when appropriate Taylor Blau
2022-10-21  5:38     ` Jeff King
2022-10-21 21:57       ` Taylor Blau
2022-10-21  3:11   ` [PATCH v2 3/6] shortlog: extract `--group` fragment for translation Taylor Blau
2022-10-21  5:40     ` Jeff King
2022-10-21  3:11   ` [PATCH v2 4/6] shortlog: support arbitrary commit format `--group`s Taylor Blau
2022-10-21  5:48     ` Jeff King
2022-10-21 22:07       ` Taylor Blau
2022-10-21  3:11   ` [PATCH v2 5/6] shortlog: implement `--group=author` in terms of `--group=<format>` Taylor Blau
2022-10-21  5:50     ` Jeff King
2022-10-21  3:11   ` [PATCH v2 6/6] shortlog: implement `--group=committer` " Taylor Blau
2022-10-21  5:51     ` Jeff King
2022-10-21  5:53   ` [PATCH v2 0/6] shortlog: introduce `--group=<format>` Jeff King
2022-10-21 22:25 ` [PATCH v3 0/7] " Taylor Blau
2022-10-21 22:25   ` [PATCH v3 1/7] shortlog: accept `--date`-related options Taylor Blau
2022-10-21 22:25   ` [PATCH v3 2/7] shortlog: make trailer insertion a noop when appropriate Taylor Blau
2022-10-21 22:25   ` [PATCH v3 3/7] shortlog: extract `--group` fragment for translation Taylor Blau
2022-10-21 22:25   ` [PATCH v3 4/7] shortlog: support arbitrary commit format `--group`s Taylor Blau
2022-10-22  0:28     ` Jeff King
2022-10-21 22:25   ` [PATCH v3 5/7] shortlog: extract `shortlog_finish_setup()` Taylor Blau
2022-10-21 22:25   ` [PATCH v3 6/7] shortlog: implement `--group=author` in terms of `--group=<format>` Taylor Blau
2022-10-21 22:25   ` [PATCH v3 7/7] shortlog: implement `--group=committer` " Taylor Blau
2022-10-22  0:31   ` [PATCH v3 0/7] shortlog: introduce `--group=<format>` Jeff King
2022-10-24 18:55 ` [PATCH " Taylor Blau
2022-10-24 18:55   ` [PATCH 1/7] shortlog: accept `--date`-related options Taylor Blau
2022-10-24 18:55   ` [PATCH 2/7] shortlog: make trailer insertion a noop when appropriate Taylor Blau
2022-10-24 18:55   ` [PATCH 3/7] shortlog: extract `--group` fragment for translation Taylor Blau
2022-10-24 18:55   ` [PATCH 4/7] shortlog: support arbitrary commit format `--group`s Taylor Blau
2022-10-24 18:55   ` [PATCH 5/7] shortlog: extract `shortlog_finish_setup()` Taylor Blau
2022-10-24 18:55   ` [PATCH 6/7] shortlog: implement `--group=author` in terms of `--group=<format>` Taylor Blau
2022-10-24 18:55   ` [PATCH 7/7] shortlog: implement `--group=committer` " Taylor Blau
2022-10-24 21:59   ` [PATCH 0/7] shortlog: introduce `--group=<format>` Junio C Hamano
2022-10-24 23:45   ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y1Iu1x6dR6GwiA2Y@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jacob@initialcommit.io \
    --cc=me@ttaylorr.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.