Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git: Ensure no backend ever takes an index lock #406

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bgw
Copy link

@bgw bgw commented Mar 6, 2025

git status (and git describe --dirty) takes an optional write lock as a performance optimization: https://git-scm.com/docs/git-status#_background_refresh

This is bad because:

  • Other processes might run at the same time, try to acquire the lock, and fail.
  • The child process can get killed for a variety of reasons, and may not be able to clean up the lock, leading to later errors about stale lockfiles.

Both of these situations are very hard to root cause and debug.

git describe does not currently support GIT_OPTIONAL_LOCKS=0 (gitgitgadget/git#1872), so this reimplements the -dirty suffix logic using git status.

This is not an issue for libgit2 or gix, but this includes tests for those backends in case they change their implementations.

bgw added a commit to vercel/next.js that referenced this pull request Mar 7, 2025
…) for napi and next-api crates to fix stale git lock files (#76889)

This does not depend on libgit2 which apparently breaks our builds on
some platforms. Instead it uses the git CLI using my PR:
rustyhorde/vergen#406

Original PR: #76773
Revert: #76879

Manually triggered CI run to try to build all platforms:
https://github.com/vercel/next.js/actions/runs/13711866131
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.

1 participant