Simplify git dirty check using git status#410
Open
jesses-canva wants to merge 3 commits intopure-fish:masterfrom
Open
Simplify git dirty check using git status#410jesses-canva wants to merge 3 commits intopure-fish:masterfrom
jesses-canva wants to merge 3 commits intopure-fish:masterfrom
Conversation
In large repositories, checking for untracked files is very slow, so `status.showUntrackedFiles=false` is typically set to improve `git status` performance. `_pure_prompt_git_dirty` doesn't use `git status` however, but three separate `git` commands to check for staged changes, unstaged changes and untracked files. The command for untracked files is `git ls-files --others` which doesn't respect `status.showUntrackedFiles=false`. Instead we can check for non-empty output from `git status --porcelain`, which checks all three of these things in one command and respects `status.showUntrackedFiles=false`. This reduces `_pure_prompt_git_dirtry` runtime from 9.3s to 0.8s on our repository.
edouard-lopez
requested changes
Mar 2, 2026
Member
edouard-lopez
left a comment
There was a problem hiding this comment.
Thanks,
the git commands were pretty old, and we haven't reviewed them in a long time.
Performance increase sound huge!
How does that impact smaller repos when used without status.showUntrackedFiles=false?
Could you update the doc by adding:
1.a quick reference to the Git section about big repo to send back to the Troubleshooting section, e.g. using Mkdocs admonition.
2. add an entry to the Troubleshooting component to add your remark about large repo
Author
Using this repo as an example, it is a bit faster, probably just because its 1 command instead of (up to) 3, but the data is noisy: |
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.
In large repositories, checking for untracked files is very slow, so
status.showUntrackedFiles=falseis typically set to improvegit statusperformance._pure_prompt_git_dirtydoesn't usegit statushowever, but three separategitcommands to check for staged changes, unstaged changes and untracked files. The command for untracked files isgit ls-files --otherswhich doesn't respectstatus.showUntrackedFiles=false.Instead we can check for non-empty output from
git status --porcelain, which checks all three of these things in one command and respectsstatus.showUntrackedFiles=false.This reduces
_pure_prompt_git_dirtryruntime from 9.3s to 0.8s on our repository.