Repository navigation
fix(config): wait for a shared git config lock on first run - #3199
Conversation
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.
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 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".
… 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.
|
@codex review |
|
Codex Review: Didn't find any major issues. Hooray! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
The |
fengmk2
left a comment
There was a problem hiding this comment.
I will merge it after the 1.4.0 version is released.
Context
vp configin linked worktrees fail with "could not lock config file" #2959Linked worktrees share one
.git/config. While worktree A writes to it,config.lockexists, so thegit configcommand of worktree B fails with exit code 255. Git 2.55 and earlier do not wait for the lock. As a result,vp configexits with code 1 and thepreparescript stops the install.With this change,
vp configretries agit configwrite that failed because of the lock. The first wait is 50 ms, and each next wait is two times longer.vp configretries a maximum of 5 times. Before each retry,vp configreads the config value. If another worktree already wrote the same value, B stops without a write and reports success.git configfails with exit code 255.vp configfails with the Git error, as before. The total wait is 1.55 s.