pub async fn acquire_worktree_config(repo: &Path) -> Result<()>Expand description
Take a reference on extensions.worktreeConfig being on for repo.
enable_worktree_config alone is only safe for one run in a repository
at a time: it is a plain get-then-set, so a second run’s “already true?”
check can see the first run’s write and conclude it owns nothing to turn
back off, while the first run’s own cleanup turns the setting off under
the second run’s feet the moment it finishes - the exact race that let a
finished run’s fold disable the hook a still-running sibling in the same
repository depended on. This ref-counts instead: the setting is turned on
once, by whichever caller is first, and turned off only once every caller
has released it via release_worktree_config.
The per-repository lock is held across the git config call for the
first acquire, so a second, concurrent acquire for the same repository
waits for it rather than racing it - without that, both could observe
“not yet counted” and both try to flip the setting on.