]> git.99rst.org Git - git.git/commit
setup: remove global `git_work_tree_cfg` variable
authorPatrick Steinhardt <redacted>
Thu, 11 Jun 2026 06:44:41 +0000 (08:44 +0200)
committerJunio C Hamano <redacted>
Thu, 11 Jun 2026 12:05:54 +0000 (05:05 -0700)
commit85f5f504f046bccf86b78ba02064a4b013d7264f
treeb62e406a821d1e91f848760ed2309ad55ba8c954
parent65eb5b989aa6d7f764d097c6759f6b6189eb0d27
setup: remove global `git_work_tree_cfg` variable

The global `git_work_tree_cfg` variable used to be modified by both
"setup.c" and by "builtin/init-db.c". We have refactored the latter user
to not use that variable at all anymore in a preceding commit, which
makes "setup.c" the only remaining user.

Even for "setup.c" it is unnecessary though, as we only ever set it to
the value we have stored in the discovered repository format. The
consequence is that we only ever set it in case we already have it set
to the same value in our discovered repository format, which makes it
redundant.

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.

Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
setup.c
git clone https://git.99rst.org/PROJECT