Skip to content

perf: skip untracked file enumeration when staging hunks of tracked files#5466

Open
renezander030 wants to merge 1 commit intojesseduffield:masterfrom
renezander030:perf/skip-untracked-on-staging-refresh
Open

perf: skip untracked file enumeration when staging hunks of tracked files#5466
renezander030 wants to merge 1 commit intojesseduffield:masterfrom
renezander030:perf/skip-untracked-on-staging-refresh

Conversation

@renezander030
Copy link
Copy Markdown

Summary

  • When staging hunks in the staging panel, git status --untracked-files=all runs on every refresh. In large repos (275k+ files) this causes multi-second delays after each staging operation.
  • Since staging hunks of a tracked file cannot affect untracked files, this PR skips their enumeration by using --untracked-files=no and preserving untracked files from the previous model state.
  • The optimization only applies when the selected file is tracked. Staging untracked files (??) still triggers a full refresh to capture the ?? > AM transition correctly.

Test plan

  • go build ./... compiles
  • go test ./pkg/commands/git_commands/... ./pkg/gui/... passes
  • Manual: stage hunks in a large repo, verify snappy response
  • Manual: stage the first hunk of a new untracked file, verify it transitions to AM correctly
  • Manual: verify untracked files remain visible in the files panel after staging tracked hunks

Fixes #5455

…iles

When staging hunks in the staging panel, lazygit refreshes the files
list by running git status --untracked-files=all. In large repos (e.g.
275k files) this directory walk dominates the refresh time, causing
multi-second delays after each staging operation.

Since staging hunks of a tracked file cannot change the set of
untracked files, we can safely skip their enumeration by using
--untracked-files=no and preserving the untracked files from the
previous model state.

The optimization is only applied when the file being staged is tracked.
Staging an untracked file (status ??) still triggers a full refresh to
correctly capture the ?? to AM transition.

Fixes jesseduffield#5455
@codacy-production
Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 6 complexity · 0 duplication

Metric Results
Complexity 6
Duplication 0

View in Codacy

TIP This summary will be updated as you push new changes. Give us feedback

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.

staging hunks or files is slow in a large repo

1 participant