]> git.ipfire.org Git - thirdparty/git.git/commit
setup: mark bogus worktree in `apply_repository_format()`
authorPatrick Steinhardt <ps@pks.im>
Tue, 30 Jun 2026 11:47:41 +0000 (13:47 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 30 Jun 2026 18:29:39 +0000 (11:29 -0700)
commitdc7afbf7a08a38844c32bec4e3107deb7b9c88cd
tree4b6695c6e0dce23576366280eba7ae3211a8e88b
parentd24c5109f7b48a404bc67f15d6bfbf68a10c9f88
setup: mark bogus worktree in `apply_repository_format()`

When a repository is configured to have both "core.worktree" and
"core.bare" we emit a warning and mark the worktree configuration as
bogus so that the next call to `setup_work_tree()` will cause us to die.
This allows us to still use the misconfigured repository, at least as
long as we don't try to use its worktree.

This condition is handled in `setup_explicit_git_dir()`. In a subsequent
commit we'll refactor this function so that it doesn't receive a repo as
input anymore though, and consequently we cannot set the "bogus" bit
anymore.

Move the logic into `apply_repository_format()` instead to prepare for
this. While at it, fix up formatting a bit.

Note that this change requires us to also explicitly unset the value of
"core.worktree" in case we have the "GIT_WORK_TREE" environment variable
set. This is because the environment variable overrides the repository's
configuration, and we don't want to warn or die in case the work tree
has been configured explicitly regardless of whether or not "core.bare"
is set.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
setup.c