Subject: Re: [PATCH 3/3] reftable: support preset file mode for writing

From: Junio C Hamano <[email-masked]>
Date: Mon, 10 Jan 2022 11:14:40 -0800

Han-Wen Nienhuys <[email-masked]> writes:

> On Fri, Dec 24, 2021 at 5:46 AM Junio C Hamano <[email-masked]> 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?

Explained in the part that follows that statement in the message you
are responding to.

> 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 are propagating executable bit, which affects both directories
and files.

> We also only write new files, so we never have to look at the existing
> mode of a file.

It is mostly about defeating the umask of whoever is esecuting "git".