git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Sunshine <sunshine@sunshineco.com>
To: "Randall S. Becker" <rsbecker@nexbridge.com>
Cc: Sean Allred <allred.sean@gmail.com>, Git List <git@vger.kernel.org>
Subject: Re: Bug report - Can create worktrees from bare repo / such worktrees can fool is_bare_repository()
Date: Sun, 19 Dec 2021 19:07:24 -0500	[thread overview]
Message-ID: <CAPig+cQs0sp8St3KxrTsuFWU0wXteKHM1DBES0s1pzBpQ0Sv=g@mail.gmail.com> (raw)
In-Reply-To: <004301d7f533$b51c0a90$1f541fb0$@nexbridge.com>

On Sun, Dec 19, 2021 at 6:54 PM <rsbecker@nexbridge.com> wrote:
> On December 19, 2021 6:30 PM, Eric Sunshine wrote:
> > `is_bare_repository_cfg` is not exactly a boolean; it's a tristate, with -1
> > meaning "not yet determined". I didn't, at the time, closely follow the
> > discussion[1] of the particular bit of code you're questioning, but the `== 1`
> > was mentioned at least a couple times, once in review by Junio[2], and then
> > in the extra patch commentary by "jtan" when he submitted v2[3]. Anyhow,
> > if I'm following the original discussion correctly, then the usage, `== 1` (or the
> > equivalent `> 0`) is probably correct, and that treating it as a simple boolean
> > (where
> > -1 is true, too) would be undesirable. (Of course, I haven't traced through the
> > init code at all, so I don't even know if it can ever be
> > -1 at this point.) Five existing consumers of this global variable use `== 1`, and
> > only two use `> 0`, so this usage is at least reasonably consistent with other
> > parts of the project.
>
> Thanks for the clarification. It helps to understand the code. Could the variable type be changed to a new typedef like ConfigTriState instead of int to be clear about its semantics? Or perhaps an enum with -1, 0, 1 declared explicitly?

I'm not sure how much value an enum would add in this particular case
since this is a quite common idiom in this codebase. It might be
sufficient merely to add a comment to its declaration in cache.h
explaining its possible values.

What could be even more helpful is some documentation about the entire
setup sequence and how all the different "is bare" and "do we have a
worktree" computations interact since the general setup logic is quite
involved, and there are likely a number of pitfalls which are not
obvious by merely glancing at the code, but which people know about
who have dealt extensively with this code (such as Duy and probably
Peff).

  reply	other threads:[~2021-12-20  0:07 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-18 16:46 Bug report - Can create worktrees from bare repo / such worktrees can fool is_bare_repository() Sean Allred
2021-12-18 17:47 ` rsbecker
2021-12-18 19:00   ` Sean Allred
2021-12-18 21:55     ` rsbecker
2021-12-19 20:16 ` Eric Sunshine
2021-12-19 20:46   ` Sean Allred
2021-12-19 21:32     ` rsbecker
2021-12-19 22:23       ` Sean Allred
2021-12-19 22:51         ` rsbecker
2021-12-19 23:30           ` Eric Sunshine
2021-12-19 23:45             ` Eric Sunshine
2021-12-19 23:54             ` rsbecker
2021-12-20  0:07               ` Eric Sunshine [this message]
2021-12-20  0:58     ` Eric Sunshine
2021-12-20 14:11       ` Derrick Stolee
2021-12-20 15:58         ` Eric Sunshine
2021-12-20 17:29           ` Derrick Stolee
2021-12-20 21:58             ` Eric Sunshine
2021-12-20 16:20         ` 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

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

  git send-email \
    --in-reply-to='CAPig+cQs0sp8St3KxrTsuFWU0wXteKHM1DBES0s1pzBpQ0Sv=g@mail.gmail.com' \
    --to=sunshine@sunshineco.com \
    --cc=allred.sean@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=rsbecker@nexbridge.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.
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 NNTP newsgroup(s).