From: Phillip Wood <phillip.wood123@gmail.com>
To: Patrick Steinhardt <ps@pks.im>, git@vger.kernel.org
Subject: Re: [PATCH] copy: drop dependency on `the_repository`
Date: Thu, 16 Jul 2026 14:41:44 +0100 [thread overview]
Message-ID: <27d4d72f-1ab5-4dc3-8cf6-1a9b6883a631@gmail.com> (raw)
In-Reply-To: <20260716-pks-copy-wo-the-repository-v1-1-8f1e078bb82f@pks.im>
Hi Patrick
On 16/07/2026 10:56, Patrick Steinhardt wrote:
> When copying a file we need to potentially adapt permissions of the new
> file based on whether or not "core.shared" is enabled. Parsing this
> configuration makes us implicitly depend on `the_repository`.
>
> Refactor the code to instead require the caller to pass in a repository
> so that we can remove `USE_THE_REPOSITORY_VARIABLE`.
Sounds sensible
> diff --git a/sequencer.c b/sequencer.c
> index 1355a99a09..c9ede9c02d 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -2419,7 +2419,7 @@ static int do_pick_commit(struct repository *r,
> } else {
> const char *dest = git_path_squash_msg(r);
> unlink(dest);
> - if (copy_file(dest, rebase_path_squash_msg(), 0666)) {
> + if (copy_file(the_repository, dest, rebase_path_squash_msg(), 0666)) {
The path for "dest" is obtained using a local repository instance "r",
but we're using "the_repository" to set the permissions on that path.
While that matches the current behavior it is clearly better to use the
same repository instance to obtain both the path and and permissions for
that path. In the hunk below we even have "the_repository" and "r" on
the same line which seems confusing. This patch uses a local repository
instance in refs/files-backend.c and setup.c, lets do the same here.
Thanks
Phillip
> res = error(_("could not copy '%s' to '%s'"),
> rebase_path_squash_msg(), dest);
> goto leave;
> @@ -3864,11 +3864,11 @@ static int error_failed_squash(struct repository *r,
> int subject_len,
> const char *subject)
> {
> - if (copy_file(rebase_path_message(), rebase_path_squash_msg(), 0666))
> + if (copy_file(the_repository, rebase_path_message(), rebase_path_squash_msg(), 0666))
> return error(_("could not copy '%s' to '%s'"),
> rebase_path_squash_msg(), rebase_path_message());
> unlink(git_path_merge_msg(r));
> - if (copy_file(git_path_merge_msg(r), rebase_path_message(), 0666))
> + if (copy_file(the_repository, git_path_merge_msg(r), rebase_path_message(), 0666))
> return error(_("could not copy '%s' to '%s'"),
> rebase_path_message(),
> git_path_merge_msg(r));
> diff --git a/setup.c b/setup.c
> index 0de56a074f..91d61a5939 100644
> --- a/setup.c
> +++ b/setup.c
> @@ -2331,7 +2331,7 @@ static void copy_templates_1(struct repository *repo,
> strbuf_release(&lnk);
> }
> else if (S_ISREG(st_template.st_mode)) {
> - if (copy_file(path->buf, template_path->buf, st_template.st_mode))
> + if (copy_file(repo, path->buf, template_path->buf, st_template.st_mode))
> die_errno(_("cannot copy '%s' to '%s'"),
> template_path->buf, path->buf);
> }
>
> ---
> base-commit: d35c5399e3e54ac277bb391fc2f6be3e816d312b
> change-id: 20260716-pks-copy-wo-the-repository-aa01ccdbed76
>
>
next prev parent reply other threads:[~2026-07-16 13:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-16 9:56 [PATCH] copy: drop dependency on `the_repository` Patrick Steinhardt
2026-07-16 13:41 ` Phillip Wood [this message]
2026-07-16 15:06 ` Patrick Steinhardt
2026-07-16 15:28 ` [PATCH v2] " Patrick Steinhardt
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=27d4d72f-1ab5-4dc3-8cf6-1a9b6883a631@gmail.com \
--to=phillip.wood123@gmail.com \
--cc=git@vger.kernel.org \
--cc=phillip.wood@dunelm.org.uk \
--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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox