You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Read-only git operations acquire unnecessary index locks (GIT_OPTIONAL_LOCKS) #22047
Desktop runs multiple git commands concurrently (e.g., background fetch + foreground status + sidebar indicator refresh). Read-only operations like diff, log, and for-each-ref acquire the index lock by default, even though they don't modify the index. This causes lock contention and occasional failures when concurrent operations compete for the lock.
Proposed solution
Set GIT_OPTIONAL_LOCKS=0 environment variable for read-only git operations:
git diff (in diff.ts)
git log (in log.ts)
git for-each-ref (in for-each-ref.ts)
From git documentation:
When set to 0, Git will complete any requested operation without performing any optional sub-operations that require taking a lock. For example, this will prevent git status from refreshing the index as a side effect.
Desktop already sets --no-optional-locks on git status. This extends the same optimization to other read-only operations.
Additionally, for-each-ref can benefit from --count=10000 to cap output on repos with massive ref counts.
This looks like a reasonable optimization request. We already use --no-optional-locks for git status, so extending a similar approach to other read-only operations makes sense in principle. We're labeling this as an
enhancement
for now, but we'd like to look into it further to understand how much lock contention is actually happening in practice before committing to a change.
A couple of notes:
Do you have evidence of actual lock failures or degraded performance caused by this? Logs, error messages, or timing data showing contention would help us prioritize this.
The --count=10000 suggestion for for-each-ref feels like a separate concern (output capping vs. lock avoidance).
We'll leave this open for evaluation. Thanks again for the suggestion!
Thank you for your issue! We have categorized it as an enhancement (feature or improvement) request, and it has been added to our backlog. In doing so, we are not committing to implementing this feature at this time, but, we will consider it for future releases based on community feedback and our own product roadmap.
Unless you see the
help wantedIssues marked as ideal for external contributors
label, we are not currently looking for external contributions for this feature.
If you come across this issue and would like to see it implemented, please add a thumbs up! This will help us prioritize the feature. Please only comment if you have additional information or viewpoints to contribute.
Activity
babakks commentedon May 14, 2026
Thanks for the detailed write-up, @coleleavitt! 🙏
This looks like a reasonable optimization request. We already use
--no-optional-locksforgit status, so extending a similar approach to other read-only operations makes sense in principle. We're labeling this as an enhancement for now, but we'd like to look into it further to understand how much lock contention is actually happening in practice before committing to a change.A couple of notes:
--count=10000suggestion forfor-each-reffeels like a separate concern (output capping vs. lock avoidance).We'll leave this open for evaluation. Thanks again for the suggestion!
github-actions commentedon May 14, 2026
Thank you for your issue! We have categorized it as an enhancement (feature or improvement) request, and it has been added to our backlog. In doing so, we are not committing to implementing this feature at this time, but, we will consider it for future releases based on community feedback and our own product roadmap.
Unless you see the help wantedIssues marked as ideal for external contributors
label, we are not currently looking for external contributions for this feature.
If you come across this issue and would like to see it implemented, please add a thumbs up! This will help us prioritize the feature. Please only comment if you have additional information or viewpoints to contribute.
Add app state, dispatcher and repository foldout
feat: app state, dispatcher, git engine foundation, repository foldout
Add app state, dispatcher and repository foldout
Add app state, dispatcher and repository foldout
feat: app state, dispatcher, git engine foundation, repository foldout