from `git` module. Actually, the function is a little bit of
over-engineering and it's currently only being used for checking the
result of `git rev-parse --is-inside-work-tree`, even in the `git`
module code.
Checking for the return code of `git rev-parse --is-inside-work-tree` is
enough. Also refactored other portions of the code where return codes
are being checked.
Fixes#161, Closes#162
The contents of git_info are subject to expansion by the shell. Avoid
putting raw ref names in the prompt to protect the user from arbitrary
code execution via specially crafted ref names (e.g., a ref named
'$(IFS=_;cmd=sudo_rm_-rf_/;$cmd)' would execute 'sudo rm -rf /' when the
prompt is drawn). Instead, put the ref names in new global variables and
reference these variables from git_info.
See:
- https://github.com/njhartwell/pw3nage
- 8976500cbbFixes#158, Closes#159
so it behaves alike the non-verbose mode. For example, in the "merge"
special action context, files are being reported as both indexed and
unindexed by `git diff-index` and `git diff-files` commands in
non-verbose mode. That was not the case with the regular expressions
used in the verbose mode.
that will be used by the minimal theme, and could be used for future
themes too. Prezto had this, but we diminished its necessity by
simplifying how git-info works.
`prompt.showinfo` for enabling or disabling it globally or per
repository. It can be globally disabled by not loading the `git-info`
module at all, and prompts currently will not break (and in the future
should still not break) if the module is not loaded.
This removes one git call that is used to check for the
`prompt.showinfo` configuration value.
that, when defined, will be set if branch is both ahead and behind of
remote. If not defined, the `ahead` and `behind` contexts will still be
set, as how they worked previously.
based on the Prezto git module
[function](https://github.com/sorin-ionescu/prezto/blob/master/modules/git/functions/git-info)
and further refactored and simplified.
What changed:
- Commit format only in 'detached HEAD' state, so
`$(coalesce "%b" "%c")` is not needed, because you only get one of
those.
- Removed the `added`, `deleted`, `modified`, `renamed` and `unmerged`
verbose contexts.
- `git status` is only used in verbose mode.
- In non-verbose mode, the `untracked` context is not available, and
also untracked files are not considered for computing the `dirty`
context. Using `git status` or checking for untracked files is
[expensive](https://gist.github.com/sindresorhus/3898739).