mirror of
https://github.com/oh-my-fish/oh-my-fish.git
synced 2025-03-10 22:15:15 +08:00

* lib/git/git_is_touched: Speed up This used to use `git status --porcelain`, which by necessity needs to check the entire repo for all kinds of changes, just to figure out if there are any. Instead, we now use git commands that can exit early. In large repos, this can be faster by a factor of 15 or so. Fixes #624. * Fix return status `git diff` also returns 1 if there *is* a diff.
9 lines
394 B
Fish
9 lines
394 B
Fish
function git_is_touched -d "Check if repo has any changes"
|
|
git_is_repo; and begin
|
|
# The first checks for staged changes, the second for unstaged ones.
|
|
# We put them in this order because checking staged changes is *fast*.
|
|
not command git diff-index --cached --quiet HEAD -- >/dev/null 2>&1
|
|
or not command git diff --no-ext-diff --quiet --exit-code >/dev/null 2>&1
|
|
end
|
|
end
|