]> git.99rst.org Git - git.git/commit
setup: mark bogus worktree in `apply_repository_format()`
authorPatrick Steinhardt <redacted>
Tue, 7 Jul 2026 07:21:21 +0000 (09:21 +0200)
committerJunio C Hamano <redacted>
Tue, 7 Jul 2026 17:49:40 +0000 (10:49 -0700)
commitc6799958b1e6c269a570e9a617986e4035e5756c
tree4b6695c6e0dce23576366280eba7ae3211a8e88b
parent9ca3ea9881a1c1e238820ce3f6a63f6ad6fce4d5
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 <redacted>
Signed-off-by: Junio C Hamano <redacted>
setup.c
git clone https://git.99rst.org/PROJECT