Git development
 help / color / mirror / Atom feed
From: Justin Tobler <jltobler@gmail.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v2 0/7] setup: drop global state
Date: Thu, 11 Jun 2026 10:47:29 -0500	[thread overview]
Message-ID: <airVOrTboNDDGBak@denethor> (raw)
In-Reply-To: <20260611-b4-pks-setup-drop-global-state-v2-0-a6f7269c841d@pks.im>

On 26/06/11 08:44AM, Patrick Steinhardt wrote:
> Hi,
> 
> this patch series continues to refactor "setup.c", where the focus is to
> drop remaining global state that we have in "setup.c". The most
> important consequence of this is that we don't need to rely on
> `the_repository` in `is_bare_repository()` anymore.
> 
> This series is built on top of 1ff279f340 (The 13th batch, 2026-06-09)
> with ps/setup-centralize-odb-creation at 42b9d3dc9d (setup: construct
> object database in `apply_repository_format()`, 2026-06-04) merged into
> it.
> 
> Changes in v2:
>   - Improve documentation for some aspects of `check_repository_format_gently()`.
>   - Link to v1: https://patch.msgid.link/20260610-b4-pks-setup-drop-global-state-v1-0-5dff3eec8f06@pks.im
> 
> Thanks!
> 
> Patrick
> 
> ---
[snip]
> Range-diff versus v1:
> 
> 1:  0281a4bca9 = 1:  96b71f5223 builtin/init: stop modifying global `git_work_tree_cfg` variable
> 2:  6fdc8d77e8 = 2:  a51c0ff79d builtin/init: simplify logic to configure worktree
> 3:  ce31595ff5 ! 3:  e06393ddc5 setup: remove global `git_work_tree_cfg` variable
>     @@ Commit message
>          Refactor the code so that we instead use the worktree configuration as
>          discovered via the repository format. Drop the global variable.
>      
>     +    Note that in `check_repository_format_gently()` we now have to free the
>     +    candidate work tree variable. This change is required to retain previous
>     +    semantics: before we essentially had an implicit `else` branch where we
>     +    set `git_work_tree_cfg = NULL`, but we were able to elide that branch
>     +    because we already knew that it would be `NULL` anyway. Now that we use
>     +    the candidate work tree directly to populate the repository's work tree
>     +    though we have to clear it to retain those semantics.

I find the additional explaination here quite helpful. Thanks.

>          Signed-off-by: Patrick Steinhardt <ps@pks.im>
>      
>       ## setup.c ##
> 4:  6a69dc853c = 4:  628ed54c8c builtin/init: stop modifying `is_bare_repository_cfg`
> 5:  afa2d8bbda ! 5:  02ceaf4a20 environment: split up concerns of `is_bare_repository_cfg`
>     @@ setup.c: static int check_repository_format_gently(const char *gitdir,
>      +		 * dictate bareness; it is inherited from the main worktree.
>      +		 */
>      +		candidate->is_bare = -1;
>     ++
>     ++		/*
>     ++		 * Furthermore, "core.worktree" is supposed to be ignored when
>     ++		 * we have a commondir configured, unless it comes from the
>     ++		 * per-worktree configuration.
>     ++		 */
>       		FREE_AND_NULL(candidate->work_tree);

Ok, so when we have a commondir set we need to clear
`candidate->work_tree` since we need to ignore core.worktree
configuration in such cases. Makes sense.

The changes in this version of the series looks good to me.

-Justin

      parent reply	other threads:[~2026-06-11 15:47 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-10  6:56 [PATCH 0/7] setup: drop global state Patrick Steinhardt
2026-06-10  6:56 ` [PATCH 1/7] builtin/init: stop modifying global `git_work_tree_cfg` variable Patrick Steinhardt
2026-06-10 21:15   ` Justin Tobler
2026-06-10  6:56 ` [PATCH 2/7] builtin/init: simplify logic to configure worktree Patrick Steinhardt
2026-06-10 21:29   ` Justin Tobler
2026-06-10  6:56 ` [PATCH 3/7] setup: remove global `git_work_tree_cfg` variable Patrick Steinhardt
2026-06-10 21:52   ` Justin Tobler
2026-06-11  6:36     ` Patrick Steinhardt
2026-06-10  6:56 ` [PATCH 4/7] builtin/init: stop modifying `is_bare_repository_cfg` Patrick Steinhardt
2026-06-10  6:56 ` [PATCH 5/7] environment: split up concerns of `is_bare_repository_cfg` Patrick Steinhardt
2026-06-10 22:22   ` Justin Tobler
2026-06-11  9:19     ` Patrick Steinhardt
2026-06-11 15:33       ` Justin Tobler
2026-06-10  6:56 ` [PATCH 6/7] environment: stop using `the_repository` in `is_bare_repository()` Patrick Steinhardt
2026-06-10  6:56 ` [PATCH 7/7] treewide: drop USE_THE_REPOSITORY_VARIABLE Patrick Steinhardt
2026-06-10 22:26   ` Justin Tobler
2026-06-11  6:44 ` [PATCH v2 0/7] setup: drop global state Patrick Steinhardt
2026-06-11  6:44   ` [PATCH v2 1/7] builtin/init: stop modifying global `git_work_tree_cfg` variable Patrick Steinhardt
2026-06-11  6:44   ` [PATCH v2 2/7] builtin/init: simplify logic to configure worktree Patrick Steinhardt
2026-06-11  6:44   ` [PATCH v2 3/7] setup: remove global `git_work_tree_cfg` variable Patrick Steinhardt
2026-06-11  6:44   ` [PATCH v2 4/7] builtin/init: stop modifying `is_bare_repository_cfg` Patrick Steinhardt
2026-06-11  6:44   ` [PATCH v2 5/7] environment: split up concerns of `is_bare_repository_cfg` Patrick Steinhardt
2026-06-11  6:44   ` [PATCH v2 6/7] environment: stop using `the_repository` in `is_bare_repository()` Patrick Steinhardt
2026-06-11  6:44   ` [PATCH v2 7/7] treewide: drop USE_THE_REPOSITORY_VARIABLE Patrick Steinhardt
2026-06-11 15:47   ` Justin Tobler [this message]

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=airVOrTboNDDGBak@denethor \
    --to=jltobler@gmail.com \
    --cc=git@vger.kernel.org \
    --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