Tested against the WebKit git repo by entering the repo with 1 file dirty.
git diff --quiet --ignore-submodules HEAD # Will tell if there are any uncomitted changes, staged or not.
0.6 sec
git diff-index --quiet HEAD # Only tracked
2 sec
git diff --shortstat
8.2 sec
git status --porcelain
42 sec
zstyle ':vcs_info:*' check-for-changes true
50 sec
git diff-index --quiet HEAD --can return outdated information unless you rungit update-index -q --refresh(or a non-plumbinggit status) first, (see https://stackoverflow.com/questions/2657935/checking-for-a-dirty-index-or-untracked-files-with-git/2659808#comment28747279_2659808) so it's not a fair comparison vsgit status --porcelainwithout that.Also any use of
git diff-index --no-ext-diff --quiet --cached HEADbreaks if there's a file calledHEADin the repo; you need to usegit diff-index --no-ext-diff --quiet --cached HEAD --, see here.Finally, I found plumbing commands to be slower than the porcelain commands when the goal is to ignore untracked files in a repo with many large untracked files (not WebKit in this case) with git 2.29.2:
time (git diff-files --quiet --no-ext-diff || (git update-index -q --refresh; git diff-index --quiet --no-ext-diff --cached HEAD --))time git status --porcelain --untracked-files=no > /dev/nullThis was also observed here.
Do there exist any plumbing commands that are as fast and as correct as the porcelain commands? (Also asked here.)