git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Elijah Newren <newren@gmail.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH 02/17] cocci: fix incorrect & verbose "the_repository" rules
Date: Sat, 18 Mar 2023 22:55:03 -0700	[thread overview]
Message-ID: <CABPp-BHaxgJthO3ww+-kJZvwU8i8kqTSFn0dwx6X8OYcQhPf_A@mail.gmail.com> (raw)
In-Reply-To: <patch-02.17-1b1fc5d41f5-20230317T152724Z-avarab@gmail.com>

On Fri, Mar 17, 2023 at 8:53 AM Ævar Arnfjörð Bjarmason
<avarab@gmail.com> wrote:
>
> When these rules started being added in [1] they didn't use a ";"
> after the ")", and would thus catch uses of these macros within
> expressions. But as of [2] the new additions were broken in that
> they'd only match a subset of the users of these macros.
>
> Rather than narrowly fixing that, let's have these use the much less
> verbose pattern introduced in my recent [3]: There's no need to
> exhaustively enumerate arguments if we use the "..." syntax. This
> means that we can fold all of these different rules into one.
>
> 1. afd69dcc219 (object-store: prepare read_object_file to deal with
>    any repo, 2018-11-13)
> 2. 21a9651ba3f (commit-reach: prepare get_merge_bases to handle any
>    repo, 2018-11-13)
> 3. 0e6550a2c63 (cocci: add a index-compatibility.pending.cocci,
>    2022-11-19)
>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
>  .../coccinelle/the_repository.pending.cocci   | 160 +++++-------------
>  1 file changed, 46 insertions(+), 114 deletions(-)
>
> diff --git a/contrib/coccinelle/the_repository.pending.cocci b/contrib/coccinelle/the_repository.pending.cocci
> index 23b97536da5..99e192736ee 100644
> --- a/contrib/coccinelle/the_repository.pending.cocci
> +++ b/contrib/coccinelle/the_repository.pending.cocci
> @@ -3,118 +3,50 @@
>  // our code base.
>
>  @@
> -expression E;
> -expression F;
> -expression G;
>  @@
> -- read_object_file(
> -+ repo_read_object_file(the_repository,
> -  E, F, G)
> -
> -@@
> -expression E;
> -@@
> -- has_object_file(
> -+ repo_has_object_file(the_repository,
> -  E)
> -
> -@@
> -expression E;
> -@@
> -- has_object_file_with_flags(
> -+ repo_has_object_file_with_flags(the_repository,
> -  E)
> -
> -@@
> -expression E;
> -expression F;
> -expression G;
> -@@
> -- parse_commit_internal(
> -+ repo_parse_commit_internal(the_repository,
> -  E, F, G)
> -
> -@@
> -expression E;
> -@@
> -- parse_commit(
> -+ repo_parse_commit(the_repository,
> -  E)
> -
> -@@
> -expression E;
> -expression F;
> -@@
> -- get_merge_bases(
> -+ repo_get_merge_bases(the_repository,
> -  E, F);
> -
> -@@
> -expression E;
> -expression F;
> -expression G;
> -@@
> -- get_merge_bases_many(
> -+ repo_get_merge_bases_many(the_repository,
> -  E, F, G);
> -
> -@@
> -expression E;
> -expression F;
> -expression G;
> -@@
> -- get_merge_bases_many_dirty(
> -+ repo_get_merge_bases_many_dirty(the_repository,
> -  E, F, G);
> -
> -@@
> -expression E;
> -expression F;
> -@@
> -- in_merge_bases(
> -+ repo_in_merge_bases(the_repository,
> -  E, F);
> -
> -@@
> -expression E;
> -expression F;
> -expression G;
> -@@
> -- in_merge_bases_many(
> -+ repo_in_merge_bases_many(the_repository,
> -  E, F, G);
> -
> -@@
> -expression E;
> -expression F;
> -@@
> -- get_commit_buffer(
> -+ repo_get_commit_buffer(the_repository,
> -  E, F);
> -
> -@@
> -expression E;
> -expression F;
> -@@
> -- unuse_commit_buffer(
> -+ repo_unuse_commit_buffer(the_repository,
> -  E, F);
> -
> -@@
> -expression E;
> -expression F;
> -expression G;
> -@@
> -- logmsg_reencode(
> -+ repo_logmsg_reencode(the_repository,
> -  E, F, G);
> -
> -@@
> -expression E;
> -expression F;
> -expression G;
> -expression H;
> -@@
> -- format_commit_message(
> -+ repo_format_commit_message(the_repository,
> -  E, F, G, H);
> +(
> +- read_object_file
> ++ repo_read_object_file
> +|
> +- has_object_file
> ++ repo_has_object_file
> +|
> +- has_object_file_with_flags
> ++ repo_has_object_file_with_flags
> +|
> +- parse_commit_internal
> ++ repo_parse_commit_internal
> +|
> +- parse_commit
> ++ repo_parse_commit
> +|
> +- get_merge_bases
> ++ repo_get_merge_bases
> +|
> +- get_merge_bases_many
> ++ repo_get_merge_bases_many
> +|
> +- get_merge_bases_many_dirty
> ++ repo_get_merge_bases_many_dirty
> +|
> +- in_merge_bases
> ++ repo_in_merge_bases
> +|
> +- in_merge_bases_many
> ++ repo_in_merge_bases_many
> +|
> +- get_commit_buffer
> ++ repo_get_commit_buffer
> +|
> +- unuse_commit_buffer
> ++ repo_unuse_commit_buffer
> +|
> +- logmsg_reencode
> ++ repo_logmsg_reencode
> +|
> +- format_commit_message
> ++ repo_format_commit_message
> +)
> +  (
> ++ the_repository,
> +  ...)
> --
> 2.40.0.rc1.1034.g5867a1b10c5

I know virtually nothing about cocci, but the commit message explains
well enough that it's clear what you're doing and what's happening.
:-)

  reply	other threads:[~2023-03-19  5:55 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-17 15:35 [PATCH 00/17] cocci: remove "the_index" wrapper macros Ævar Arnfjörð Bjarmason
2023-03-17 15:35 ` [PATCH 01/17] cocci: remove dead rule from "the_repository.pending.cocci" Ævar Arnfjörð Bjarmason
2023-03-17 16:14   ` Eric Sunshine
2023-03-19  5:53   ` Elijah Newren
2023-03-17 15:35 ` [PATCH 02/17] cocci: fix incorrect & verbose "the_repository" rules Ævar Arnfjörð Bjarmason
2023-03-19  5:55   ` Elijah Newren [this message]
2023-03-22 22:46   ` Glen Choo
2023-03-26  5:02     ` Ævar Arnfjörð Bjarmason
2023-03-17 15:35 ` [PATCH 03/17] cocci: sort "the_repository" rules by header Ævar Arnfjörð Bjarmason
2023-03-19  5:59   ` Elijah Newren
2023-03-17 15:35 ` [PATCH 04/17] cocci: add missing "the_repository" macros to "pending" Ævar Arnfjörð Bjarmason
2023-03-19  6:04   ` Elijah Newren
2023-03-17 15:35 ` [PATCH 05/17] cocci: apply the "cache.h" part of "the_repository.pending" Ævar Arnfjörð Bjarmason
2023-03-19  6:06   ` Elijah Newren
2023-03-22 23:17   ` Glen Choo
2023-03-17 15:35 ` [PATCH 06/17] cocci: apply the "commit-reach.h" " Ævar Arnfjörð Bjarmason
2023-03-17 15:35 ` [PATCH 07/17] cocci: apply the "commit.h" " Ævar Arnfjörð Bjarmason
2023-03-17 15:35 ` [PATCH 08/17] cocci: apply the "diff.h" " Ævar Arnfjörð Bjarmason
2023-03-17 15:35 ` [PATCH 09/17] cocci: apply the "object-store.h" " Ævar Arnfjörð Bjarmason
2023-03-17 15:35 ` [PATCH 10/17] cocci: apply the "pretty.h" " Ævar Arnfjörð Bjarmason
2023-03-17 15:35 ` [PATCH 11/17] cocci: apply the "packfile.h" " Ævar Arnfjörð Bjarmason
2023-03-17 15:35 ` [PATCH 12/17] cocci: apply the "promisor-remote.h" " Ævar Arnfjörð Bjarmason
2023-03-17 15:35 ` [PATCH 13/17] cocci: apply the "refs.h" " Ævar Arnfjörð Bjarmason
2023-03-17 15:35 ` [PATCH 14/17] cocci: apply the "rerere.h" " Ævar Arnfjörð Bjarmason
2023-03-17 15:35 ` [PATCH 15/17] cocci: apply the "revision.h" " Ævar Arnfjörð Bjarmason
2023-03-22 23:38   ` Glen Choo
2023-03-22 23:53     ` Glen Choo
2023-03-26  4:59       ` Ævar Arnfjörð Bjarmason
2023-03-17 15:35 ` [PATCH 16/17] post-cocci: adjust comments for recent repo_* migration Ævar Arnfjörð Bjarmason
2023-03-19  6:12   ` Elijah Newren
2023-03-17 15:35 ` [PATCH 17/17] libs: use "struct repository *" argument, not "the_repository" Ævar Arnfjörð Bjarmason
2023-03-19  6:19   ` Elijah Newren
2023-03-28 10:53     ` Ævar Arnfjörð Bjarmason
2023-03-17 19:22 ` [PATCH 00/17] cocci: remove "the_index" wrapper macros Junio C Hamano
2023-03-28 13:58 ` [PATCH v2 00/17] cocci: remove "the_repository" " Ævar Arnfjörð Bjarmason
2023-03-28 13:58   ` [PATCH v2 01/17] cocci: remove dead rule from "the_repository.pending.cocci" Ævar Arnfjörð Bjarmason
2023-03-28 13:58   ` [PATCH v2 02/17] cocci: fix incorrect & verbose "the_repository" rules Ævar Arnfjörð Bjarmason
2023-03-29 20:35     ` Taylor Blau
2023-03-28 13:58   ` [PATCH v2 03/17] cocci: sort "the_repository" rules by header Ævar Arnfjörð Bjarmason
2023-03-28 13:58   ` [PATCH v2 04/17] cocci: add missing "the_repository" macros to "pending" Ævar Arnfjörð Bjarmason
2023-03-28 13:58   ` [PATCH v2 05/17] cocci: apply the "cache.h" part of "the_repository.pending" Ævar Arnfjörð Bjarmason
2023-03-28 13:58   ` [PATCH v2 06/17] cocci: apply the "commit-reach.h" " Ævar Arnfjörð Bjarmason
2023-03-28 13:58   ` [PATCH v2 07/17] cocci: apply the "commit.h" " Ævar Arnfjörð Bjarmason
2023-03-28 13:58   ` [PATCH v2 08/17] cocci: apply the "diff.h" " Ævar Arnfjörð Bjarmason
2023-03-28 13:58   ` [PATCH v2 09/17] cocci: apply the "object-store.h" " Ævar Arnfjörð Bjarmason
2023-03-28 13:58   ` [PATCH v2 10/17] cocci: apply the "pretty.h" " Ævar Arnfjörð Bjarmason
2023-03-28 13:58   ` [PATCH v2 11/17] cocci: apply the "packfile.h" " Ævar Arnfjörð Bjarmason
2023-03-28 13:58   ` [PATCH v2 12/17] cocci: apply the "promisor-remote.h" " Ævar Arnfjörð Bjarmason
2023-03-28 13:58   ` [PATCH v2 13/17] cocci: apply the "refs.h" " Ævar Arnfjörð Bjarmason
2023-03-28 13:58   ` [PATCH v2 14/17] cocci: apply the "rerere.h" " Ævar Arnfjörð Bjarmason
2023-03-28 13:58   ` [PATCH v2 15/17] cocci: apply the "revision.h" " Ævar Arnfjörð Bjarmason
2023-03-28 13:58   ` [PATCH v2 16/17] post-cocci: adjust comments for recent repo_* migration Ævar Arnfjörð Bjarmason
2023-03-29 20:50     ` Taylor Blau
2023-03-28 13:58   ` [PATCH v2 17/17] libs: use "struct repository *" argument, not "the_repository" Ævar Arnfjörð Bjarmason
2023-03-28 14:09   ` [PATCH v2 00/17] cocci: remove "the_repository" wrapper macros Junio C Hamano
2023-03-28 14:34     ` Junio C Hamano
2023-03-29 19:02   ` Junio C Hamano
2023-03-29 22:04     ` Taylor Blau
2023-03-30  3:55     ` Elijah Newren
2023-03-30 18:08     ` Glen Choo

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=CABPp-BHaxgJthO3ww+-kJZvwU8i8kqTSFn0dwx6X8OYcQhPf_A@mail.gmail.com \
    --to=newren@gmail.com \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).