Some git commands require to be run from inside the worktree (as opposed
to the git dir, although it's usually in .git). This commit adds
a function git_is_worktree to check this. It is used for the commands
that need the worktree instead of git_is_repo.
An alternative solution might have been to find the git worktree in the
parent of the git directory, but this doesn't work for all cases.
Generally it's impossible to detect the location of the worktree (plus
it's not unique).
Co-authored-by: Pablo Aguiar <scorphus@gmail.com>
* 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.