git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v3] worktree: detect from secondary worktree if main worktree is bare

From
Olga Pilipenco <olga.pilipenco@shopify.com>
Date
Feb 4, 2025, 20:33 UTC
Message-ID
<CAFLeGL7aewQTECw3sUPSgysaWCcS+U_7vf=uHDuuvKDkQUHfxA@mail.gmail.com>
In-Reply-To
<xmqqa5b1ts0y.fsf@gitster.g>
On Tue, Feb 4, 2025 at 12:43 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 46 quoted lines
>
> Olga Pilipenco <olga.pilipenco@shopify.com> writes:
>
> > I have 2 versions for comment:
> >
> > 1. Since is_main_worktree_bare explains quite well what it does we can have
> > a shorter explanation of `!worktree->is_current` part, something like:
> >
> > /* Additional checks are needed if main worktree is not current
> > (checking from secondary worktree) */
> > (!worktree->is_current && is_main_worktree_bare(the_repository));
>
> For somebody who thought about the issue themselves (like me, before
> writing the message you are responding to), this shorter form would
> suffice.  I'd rephrase it more like so
>
>     /* When a secondary worktree, an extra check is needed */
>
> for brevity, though.
>
>
> > 2. Or a bit longer inline explanation that partially repeats the
> > explanation of is_main_worktree_bare
> > + adds explanation about efficiency:
> >  /*
> >   * When in a secondary worktree we have to also verify if the main worktree
> >   * is bare in $commondir/config.worktree.
> >   * This check is unnecessary if we're currently in the main worktree,
> >   * as prior checks already consulted all configs of the current worktree.
> >  */
> > (!worktree->is_current && is_main_worktree_bare(the_repository));
>
> And this more extended version would have helped me by not having to
> ask
>
>     Is "this worktree does not have is_current bit set" equivalent
>     to "this worktree is the main one, so is_main_worktree_bare()
>     needs to be consulted"?  That linkage between "the is_current
>     bit unset" and "is the main worktree" is not obvious to me.
>
> in the first place.
>
> In short, both should work, and I personally find that the latter
> may be a bit more helpful to readers.
>
> THanks.
Perfect, I'll add the latter one then. Thank you!
Previous: Junio C HamanoNext: Olga Pilipenco via GitGitGadget
Message 14 of 19 in “worktree: detect from secondary worktree if main worktree is bare”
  1. worktree: detect from secondary worktree if main worktree is bareOlga Pilipenco via GitGitGadget, Nov 15, 2024
  2. worktree: detect from secondary worktree if main worktree is bareOlga Pilipenco via GitGitGadget, Jan 16, 2025
  3. Eric SunshineJan 19, 2025
  4. Olga PilipencoJan 28, 2025
  5. Eric SunshineJan 29, 2025
  6. Junio C HamanoJan 29, 2025
  7. worktree: detect from secondary worktree if main worktree is bareOlga Pilipenco via GitGitGadget, Jan 31, 2025
  8. Junio C HamanoJan 31, 2025
  9. Junio C HamanoJan 31, 2025
  10. Olga PilipencoJan 31, 2025
  11. Junio C HamanoJan 31, 2025
  12. Olga PilipencoFeb 4, 2025
  13. Junio C HamanoFeb 4, 2025
  14. Olga PilipencoFeb 4, 2025
  15. worktree: detect from secondary worktree if main worktree is bareOlga Pilipenco via GitGitGadget, Feb 5, 2025
  16. Eric SunshineJan 30, 2025
  17. Eric SunshineJan 30, 2025
  18. Olga PilipencoJan 31, 2025
  19. Eric SunshineJan 31, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.