Repository navigation
perf(git): speed up CLI backend startup - #568
Merged
Merged
Conversation
idriss-mortadi
marked this pull request as draft
August 6, 2026 08:20
idriss-mortadi
marked this pull request as ready for review
August 6, 2026 09:17
agavra
approved these changes
Aug 11, 2026
| fn get_cli_change_status(workdir: &Path) -> Result<VcsChangeStatus> { | ||
| let output = Command::new("git") | ||
| .current_dir(workdir) | ||
| .args(["status", "--porcelain=v1", "-z", "--untracked-files=normal"]) |
Owner
There was a problem hiding this comment.
any reason why we have to force v1? seems like Claude thinks this hsould work with git v2 clients as well
Contributor
Author
There was a problem hiding this comment.
v1 is the output format. it is not the git client version. git 2 clients support this format.
we only need the two status columns from v1. the parser reads those first two bytes. v2 has a different and richer record format that we do not need here.
--porcelain defaults to v1 today. writing =v1 makes the parser contract explicit.
Contributor
Author
There was a problem hiding this comment.
Also, git status 's porcelain flag defaults to v1. See https://git-scm.com/docs/git-status#Documentation/git-status.txt---porcelainversion
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #560.
Context
backend = "cli"already exists. It selects native Git for all Git operations. This PR improves startup when that setting is enabled. The default libgit2 backend is unchanged.Problem
The CLI backend runs separate probes for staged, tracked unstaged, and untracked files. Untracked discovery is slow in large repositories.
Measured in a large monorepo:
Change
Standard Git repositories now use one machine-readable probe:
The parser folds Git's two status columns into staged and unstaged booleans. It also handles the extra pathname emitted for renames and copies.
--untracked-files=normalis explicit. Without it,status.showUntrackedFiles=nocan hide an untracked-only worktree. tuicr would then hide the Unstaged changes row. An integration test covers this repository configuration.Sparse checkout and sparse index repositories keep the existing scoped probes. Plain
git statuscan report untracked files outside the sparse cone.Git already applies
.gitignoreduring status. tuicr only enumerates paths when.tuicrignoreadds application-specific rules. This condition lives in generic app code. Today, onlyGitCliBackendreturns a successful cheap status result, so only that backend takes the new path. The libgit2, Jujutsu, and Mercurial behavior remains unchanged.Result
With
backend = "cli":Recording
The recording uses a synthetic repository with 1,000,001 tracked files. It contains no private source or repository metadata. Both runs use a warm filesystem cache and
backend = "cli".The recorded synthetic benchmark measured 5.96s before and 339ms after.
reproduce the synthetic benchmark
this script checks required tools, commit availability, free disk space, and platform support. it builds both revisions and creates a temporary synthetic repository. it removes all temporary files when it exits.
Validation
cargo test: 1300 passed, 2 ignoredcargo check --all-targets: passedstatus.showUntrackedFiles=nointegration test: passedcargo clippy --all-targets -- -D warningsremains blocked by the existingitems_after_test_modulefinding insrc/handler.rs:577.