jesseduffield.lazygit/pkg/commands
Stefan Haller d94f2f05ac Only pass --no-optional-locks for background status refreshes
We set GIT_OPTIONAL_LOCKS=0 for every git command we run. That env var
only affects `git status`: it tells git not to take the optional lock it
would otherwise use to write the index back after refreshing the cached
stat information. The intent was to avoid contending for index.lock with
git commands the user runs in a terminal.

The downside is that our `git status` never persists the refreshed
stat-cache. So whenever the working tree's cached stat info goes stale
(e.g. editing files and discarding the changes, or a checkout), every
subsequent status re-hashes the affected files to confirm they're clean,
and stays slow until something else writes the index (such as the user
running `git status` in a terminal).

Fix this by only suppressing optional locks for refreshes that run
unattended in the background; foreground refreshes triggered by a user
action now run a plain `git status` that writes the refreshed index back,
just like the command line does. Background refreshes keep passing
--no-optional-locks so they still can't cause lock contention.

RefreshOptions gains a Background flag that the background routines set,
threaded down to the status command.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 18:14:24 +02:00
..
direnv Offer direnv .envrc approval from inside lazygit 2026-06-04 09:05:01 +02:00
git_commands Only pass --no-optional-locks for background status refreshes 2026-06-19 18:14:24 +02:00
git_config Enable errorlint linter, and fix warnings 2025-06-30 18:30:11 +02:00
hosting_service Optimize regex compilations 2026-05-10 15:28:14 +02:00
models Add PushUrls field to models.Remote 2026-05-04 13:09:47 +02:00
oscommands Log CPU time of external commands in addition to wall-clock time 2026-06-19 18:07:48 +02:00
patch Fix selection after staging an added line 2026-03-19 16:57:53 +01:00
testdata Support opening lazygit in a submodule 2019-05-12 17:59:49 +10:00
git.go Add GitHub commands and model for fetching PR status 2026-04-01 09:13:55 +02:00
git_cmd_obj_builder.go Only pass --no-optional-locks for background status refreshes 2026-06-19 18:14:24 +02:00
git_cmd_obj_runner.go retry on ref lock errors during fetch/pull 2026-04-20 09:04:50 +02:00