For example, "git diff" would print
"fatal: this operation must be run in a work tree"
We could still run git_branch_name in bare repositories in future.
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.
Refactor autoload: Split the big function into two smaller ones,
doing only option parsing at main function.
The algorithm is also rewritten, now in two steps for both path
inclusion an exclusion functions: 1) use auxiliary lists to store
valid function and completion paths, 2) bulk insert or remove just
once in the variable.
Now also respects path insertion policy, keeping user function
path always in front of other paths, thus allowing precedence of
user functions.
* init: rewrite init process
Now use pure globbing to generate 100% valid function and
completion paths, effectively splitting the init process in two
steps, one which paths are added, and other when initialization
is done (sourcing init).
This initialization code introduces a new interface for
`init.fish` hook, which deprecates the previously used event
model. The new interface injects three variables into `init.fish`:
path, package and bundle. This variables can be used by the
package to autoload paths, use bundled files, etc.
Also supports key bindings by sourcing
$OMF_CONFIG/key_bindings.fish and also key_bindings.fish in
packages (plugins and themes) root directories. This is done
when fish_user_key_bindings is called.
* omf: migrate to new init hook
* omf/templates: migrate to new init and uninstall hooks
* docs: document new init and uninstall hooks interface
* README: update new hook interface spec
With great power comes great responsibility. This function is
somewhat low level, and is harmful to shell's user, as it
completely screws up with job control (subprocesses).
This PR officially marks `refresh` as deprecated, moving the
deprecated functionality to omf plugin `compat` quarantine
directory.
Fixes an issue with history between shell reloads via refresh function call.
As `exec` replaces the current process in a non-gently fashion, the
persistent history could be out of sync with the in-memory history.
Calling `history --save` before `exec` should force the shell to persist the
history before replacing the current process.