Skip to content

fix(config): wait for a shared git config lock on first run - #3199

Merged
fengmk2 merged 6 commits into
voidzero-dev:mainfrom
naokihaba:naokihaba/investigate-issue-2959
Oct 23, 2026
Merged

fengmk2 merged 6 commits into
voidzero-dev:mainfrom
naokihaba:naokihaba/investigate-issue-2959

Conversation

@naokihaba

Copy link
Copy Markdown
Collaborator

Context

Linked worktrees share one .git/config. While worktree A writes to it, config.lock exists, so the git config command of worktree B fails with exit code 255. Git 2.55 and earlier do not wait for the lock. As a result, vp config exits with code 1 and the prepare script stops the install.

With this change, vp config retries a git config write that failed because of the lock. The first wait is 50 ms, and each next wait is two times longer. vp config retries a maximum of 5 times. Before each retry, vp config reads the config value. If another worktree already wrote the same value, B stops without a write and reports success.

  1. A takes the lock and writes the value.
  2. B tries to write. The lock exists, so git config fails with exit code 255.
  3. B waits 50 ms and reads the config value.
  4. If A already wrote the same value, B stops without a write and reports success.
  5. If the value is not there, B tries to write again. If the write fails again, B waits 100, 200, 400, and then 800 ms and starts again from step 3.
  6. If the lock still exists after the last wait, vp config fails with the Git error, as before. The total wait is 1.55 s.

Linked worktrees share one `.git/config`. When `vp config` runs for the
first time in several worktrees at once, a write can find `config.lock`
held by another worktree. Git older than 2.56 then fails at once, so the
`prepare` script exits with code 1 and the install stops.

Write git config through `writeGitConfig`. When Git exits with 255
(CONFIG_NO_LOCK), wait 50-800 ms and read the value again. All worktrees
write the same values, so the run succeeds when another run has already
stored them. Pass `-c core.configLockTimeout=0` so that the wait is the
same on every Git version.

`install()` now writes `core.hooksPath` through `gitConfigSet`, so this
write also uses `--local`, like the other hook keys.

Closes voidzero-dev#2959
Record what `vp config` prints when another run holds `config.lock` for
the whole first run: it retries, then exits with code 1 and the Git
error. After the lock is released, the next run writes the git config.
@naokihaba naokihaba self-assigned this Oct 22, 2026
@naokihaba

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-22T16:30:44.716663Z 67a0671 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c7adf3c8f1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/cli/src/config/hooks.ts
Comment thread packages/cli/src/config/hooks.ts Outdated
… a lock failure

Git returns CONFIG_NO_LOCK (-1) when it cannot take `config.lock`. Git
2.37+ keeps the low 8 bits on every platform, so the exit code is 255.
Older Git for Windows can keep the full 32-bit value, 4294967295. Retry
on both values.
@naokihaba

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 67a0671e9a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@naokihaba

Copy link
Copy Markdown
Collaborator Author

The CLI snapshot test (x86_64-unknown-linux-gnu, shard 2/3) job failed in the "Install Nushell" step at 16:26 UTC. At the same time, GitHub reported degraded performance for API Requests and Actions on https://www.githubstatus.com/. The failure is not related to this change. I will re-run the failed jobs after GitHub recovers.

@naokihaba
naokihaba requested a review from fengmk2 October 22, 2026 22:51
@naokihaba
naokihaba marked this pull request as ready for review October 22, 2026 22:51

@fengmk2 fengmk2 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will merge it after the 1.4.0 version is released.

@fengmk2
fengmk2 merged commit d3d9f57 into voidzero-dev:main Oct 23, 2026
47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Concurrent first runs of vp config in linked worktrees fail with "could not lock config file"

2 participants