From: Han-Wen Nienhuys <hanwen@google.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Han-Wen Nienhuys via GitGitGadget <gitgitgadget@gmail.com>,
git@vger.kernel.org, Han-Wen Nienhuys <hanwenn@gmail.com>
Subject: Re: [PATCH 3/3] reftable: support preset file mode for writing
Date: Mon, 10 Jan 2022 20:01:54 +0100 [thread overview]
Message-ID: <CAFQ2z_MEN2j-sHmGK4SA6N8P9bHvjO2=+G0XxXp_9vzLRxwKuw@mail.gmail.com> (raw)
In-Reply-To: <xmqqsfui4nkr.fsf@gitster.g>
On Fri, Dec 24, 2021 at 5:46 AM Junio C Hamano <gitster@pobox.com> wrote:
> > if (add->lock_file_fd < 0) {
> > if (errno == EEXIST) {
> > err = REFTABLE_LOCK_ERROR;
> > @@ -478,6 +478,13 @@ static int reftable_stack_init_addition(struct reftable_addition *add,
> > }
> > goto done;
> > }
> > + if (st->config.default_permissions) {
> > + if (chmod(add->lock_file_name.buf, st->config.default_permissions) < 0) {
> > + err = REFTABLE_IO_ERROR;
> > + goto done;
>
> This part does not exactly make sense, though.
why?
> If this were a library code meant to link with ONLY with Git, I
> would have recommended to make a adjust_shared_perm() call from
> here, without having to have "unsigned int default_permissions" to
> reftable_write_options structure.
>
> I wonder if it is a better design to make the new member in the
> structure a pointer to a generic and opaque helper function that is
> called from here, i.e.
>
> if (st->config.adjust_perm &&
> st->config.adjust_perm(add->lock_file_name.buf) < 0) {
> err = REFTABLE_IO_ERROR;
> goto done;
> }
>
> so that when linking with and calling from git, we can just stuff
> the pointer to adjust_shared_perm function to the member?
I read over the adjust_shared_perm function for a bit, but I'm puzzled
why its complexity is necessary. It seems to do something with X-bits,
maybe for directories, but that doesn't apply here as we're only
handling files?
We also only write new files, so we never have to look at the existing
mode of a file.
With the current approach, the option is very clear about what it
does, and the unittest is straightforward: set the option, do a write,
and check that the files have the specified mode.
--
Han-Wen Nienhuys - Google Munich
I work 80%. Don't expect answers from me on Fridays.
--
Google Germany GmbH, Erika-Mann-Strasse 33, 80636 Munich
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Geschäftsführer: Paul Manicle, Halimah DeLaine Prado
next prev parent reply other threads:[~2022-01-10 19:02 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-23 19:29 [PATCH 0/3] preliminary fixes for reftable support Han-Wen Nienhuys via GitGitGadget
2021-12-23 19:29 ` [PATCH 1/3] reftable: fix typo in header Han-Wen Nienhuys via GitGitGadget
2021-12-23 19:29 ` [PATCH 2/3] reftable: signal overflow Han-Wen Nienhuys via GitGitGadget
2021-12-23 19:29 ` [PATCH 3/3] reftable: support preset file mode for writing Han-Wen Nienhuys via GitGitGadget
2021-12-24 4:46 ` Junio C Hamano
2022-01-10 19:01 ` Han-Wen Nienhuys [this message]
2022-01-10 19:14 ` Junio C Hamano
2021-12-23 20:27 ` [PATCH 0/3] preliminary fixes for reftable support Junio C Hamano
2021-12-24 2:15 ` Junio C Hamano
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='CAFQ2z_MEN2j-sHmGK4SA6N8P9bHvjO2=+G0XxXp_9vzLRxwKuw@mail.gmail.com' \
--to=hanwen@google.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=gitster@pobox.com \
--cc=hanwenn@gmail.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).