Skip to content

Commit

Permalink
agnoster: fix git working tree check (#9072)
Browse files Browse the repository at this point in the history
`git rev-parse --is-inside-work-tree` does not have a different exit
code when not within a work tree; the difference is in the output,
either "true" when in a work tree, or "false" when not.

The if was modified similarly to the check for the hide-status config,
which also parses command output rather than exit code.

Co-authored-by: Kyle Laker <klaker@easydynamics.com>
  • Loading branch information
laurelmay and Kyle Laker committed Jul 1, 2020
1 parent 232cb19 commit d24a9db
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion themes/agnoster.zsh-theme
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ prompt_git() {
}
local ref dirty mode repo_path

if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
if [[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]]; then
repo_path=$(git rev-parse --git-dir 2>/dev/null)
dirty=$(parse_git_dirty)
ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="$(git rev-parse --short HEAD 2> /dev/null)"
Expand Down

0 comments on commit d24a9db

Please sign in to comment.