git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Taylor Blau <me@ttaylorr.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 4/5] cocci: apply rules to rewrite callers of "refs" interfaces
Date: Fri, 3 May 2024 14:48:52 -0400	[thread overview]
Message-ID: <ZjUxlLyyvmHNifDp@nand.local> (raw)
In-Reply-To: <5109468b356637b8b4521a3e96ba228622804ca0.1714717057.git.ps@pks.im>

On Fri, May 03, 2024 at 08:28:14AM +0200, Patrick Steinhardt wrote:
> Apply the rules that rewrite callers of "refs" interfaces to explicitly
> pass `struct ref_store`. The resulting patch has been applied with the
> `--whitespace=fix` option.
>
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
>  add-interactive.c           | 17 +++++++----
>  bisect.c                    | 25 ++++++++++-----
>  blame.c                     |  4 +--
>  branch.c                    |  5 +--
>  builtin/am.c                | 38 ++++++++++++++---------
>  builtin/bisect.c            | 44 +++++++++++++++-----------
>  builtin/blame.c             |  4 +--
>  builtin/branch.c            | 49 ++++++++++++++++-------------
>  builtin/checkout.c          | 35 +++++++++++++--------
>  builtin/clone.c             | 36 +++++++++++++---------
>  builtin/describe.c          |  3 +-
>  builtin/fast-import.c       | 11 ++++---
>  builtin/fetch.c             | 20 ++++++++----
>  builtin/fsck.c              | 11 +++++--
>  builtin/gc.c                |  3 +-
>  builtin/log.c               |  6 ++--
>  builtin/merge.c             | 34 +++++++++++++--------
>  builtin/name-rev.c          |  5 +--
>  builtin/notes.c             | 26 +++++++++-------
>  builtin/pack-objects.c      | 10 ++++--
>  builtin/pull.c              |  2 +-
>  builtin/rebase.c            | 18 ++++++-----
>  builtin/receive-pack.c      | 15 ++++++---
>  builtin/reflog.c            | 25 ++++++++-------
>  builtin/remote.c            | 37 +++++++++++++---------
>  builtin/repack.c            |  7 +++--
>  builtin/replace.c           |  9 +++---
>  builtin/reset.c             | 13 +++++---
>  builtin/rev-parse.c         | 25 ++++++++++-----
>  builtin/show-branch.c       | 22 ++++++++-----
>  builtin/show-ref.c          | 19 ++++++++----
>  builtin/stash.c             | 23 ++++++++------
>  builtin/submodule--helper.c |  7 +++--
>  builtin/symbolic-ref.c      | 13 +++++---
>  builtin/tag.c               | 11 ++++---
>  builtin/update-index.c      |  2 +-
>  builtin/update-ref.c        | 21 ++++++++-----
>  builtin/worktree.c          | 19 +++++++-----
>  bundle-uri.c                | 12 +++++---
>  bundle.c                    |  2 +-
>  commit-graph.c              |  3 +-
>  commit.c                    |  3 +-
>  config.c                    |  3 +-
>  delta-islands.c             |  3 +-
>  fetch-pack.c                |  6 ++--
>  fmt-merge-msg.c             |  4 ++-
>  help.c                      |  5 +--
>  http-backend.c              | 13 +++++---
>  log-tree.c                  |  9 ++++--
>  ls-refs.c                   | 10 +++---
>  midx-write.c                |  3 +-
>  negotiator/default.c        |  3 +-
>  negotiator/skipping.c       |  3 +-
>  notes-cache.c               |  6 ++--
>  notes-merge.c               |  2 +-
>  notes-utils.c               |  7 +++--
>  notes.c                     |  5 +--
>  reachable.c                 |  5 +--
>  ref-filter.c                | 35 +++++++++++++++------
>  reflog-walk.c               | 27 +++++++++++-----
>  reflog.c                    | 20 +++++++-----
>  refs.c                      |  9 ++++--
>  remote.c                    | 38 ++++++++++++++---------
>  reset.c                     | 29 ++++++++++--------
>  revision.c                  | 27 ++++++++++------
>  sequencer.c                 | 61 ++++++++++++++++++++-----------------
>  server-info.c               |  3 +-
>  setup.c                     |  2 +-
>  shallow.c                   | 16 ++++++----
>  submodule.c                 |  6 ++--
>  transport-helper.c          | 29 ++++++++++--------
>  transport.c                 | 16 ++++++----
>  upload-pack.c               | 20 +++++++-----
>  walker.c                    |  6 ++--
>  wt-status.c                 | 22 +++++++------
>  75 files changed, 711 insertions(+), 436 deletions(-)
>
> diff --git a/add-interactive.c b/add-interactive.c
> index e17602b5e4..b5d6cd689a 100644
> --- a/add-interactive.c
> +++ b/add-interactive.c
> @@ -532,8 +532,9 @@ static int get_modified_files(struct repository *r,
>  			      size_t *binary_count)
>  {
>  	struct object_id head_oid;
> -	int is_initial = !resolve_ref_unsafe("HEAD", RESOLVE_REF_READING,
> -					     &head_oid, NULL);
> +	int is_initial = !refs_resolve_ref_unsafe(get_main_ref_store(the_repository),
> +						  "HEAD", RESOLVE_REF_READING,
> +						  &head_oid, NULL);
>  	struct collection_status s = { 0 };
>  	int i;

OK, so this is the patch that applies the Coccinelle script from the
previous step.

This all makes sense, but I wonder if we should be more careful than
blindly replacing these functions with the same set of arguments
following a new

    get_main_ref_store(the_repository)

For instance, in this hunk, we have a 'struct repository *' in scope via
the 'r' parameter in add-interactive.c::get_modified_files().

I don't think it's wrong per-se to use the_repository here, but it does
create something to clean up in the future.

I haven't looked at other spots throughout this patch, just noticed
this in the first hunk and thought that I'd say something about it.
Otherwise the transformation seems obviously correct.

Thanks,
Taylor


  reply	other threads:[~2024-05-03 18:49 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-03  6:27 [PATCH 0/5] refs: remove functions without ref store Patrick Steinhardt
2024-05-03  6:27 ` [PATCH 1/5] refs: introduce missing functions that accept a `struct ref_store` Patrick Steinhardt
2024-05-03 17:11   ` Junio C Hamano
2024-05-03  6:28 ` [PATCH 2/5] refs: add `exclude_patterns` parameter to `for_each_fullref_in()` Patrick Steinhardt
2024-05-03 18:44   ` Taylor Blau
2024-05-03  6:28 ` [PATCH 3/5] cocci: introduce rules to transform "refs" to pass ref store Patrick Steinhardt
2024-05-03  6:28 ` [PATCH 4/5] cocci: apply rules to rewrite callers of "refs" interfaces Patrick Steinhardt
2024-05-03 18:48   ` Taylor Blau [this message]
2024-05-03 19:20     ` Junio C Hamano
2024-05-06  6:35       ` Patrick Steinhardt
2024-05-03  6:28 ` [PATCH 5/5] refs: remove functions without ref store Patrick Steinhardt
2024-05-06  1:15   ` James Liu
2024-05-03 17:24 ` [PATCH 0/5] " Junio C Hamano
2024-05-03 17:35   ` Jeff King
2024-05-03 18:24     ` Junio C Hamano
2024-05-06  6:44       ` Patrick Steinhardt
2024-05-06 16:14         ` Junio C Hamano
2024-05-07  5:56           ` Patrick Steinhardt
2024-05-07  6:20             ` Junio C Hamano
2024-05-07  6:30               ` Patrick Steinhardt
2024-05-07 15:46                 ` Junio C Hamano
2024-05-09 16:55         ` Jeff King
2024-05-10  5:54           ` Patrick Steinhardt
2024-05-03 18:58     ` Taylor Blau
2024-05-03 19:35       ` Junio C Hamano
2024-05-07  7:11 ` [PATCH v2 " Patrick Steinhardt
2024-05-07  7:11   ` [PATCH v2 1/5] refs: introduce missing functions that accept a `struct ref_store` Patrick Steinhardt
2024-05-07  7:11   ` [PATCH v2 2/5] refs: add `exclude_patterns` parameter to `for_each_fullref_in()` Patrick Steinhardt
2024-05-07  7:11   ` [PATCH v2 3/5] cocci: introduce rules to transform "refs" to pass ref store Patrick Steinhardt
2024-05-07  7:11   ` [PATCH v2 4/5] cocci: apply rules to rewrite callers of "refs" interfaces Patrick Steinhardt
2024-05-07  7:11   ` [PATCH v2 5/5] refs: remove functions without ref store Patrick Steinhardt
2024-05-07 17:27   ` [PATCH v2 0/5] " Taylor Blau

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=ZjUxlLyyvmHNifDp@nand.local \
    --to=me@ttaylorr.com \
    --cc=git@vger.kernel.org \
    --cc=ps@pks.im \
    /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).