d24a9dbcccd03f4e1dd4549c94e9c3fe76d88f4b

Author
Kyle Laker <kyle@laker.email>
Committer
GitHub <noreply@github.com>
Date

Message

agnoster: fix git working tree check (#9072)

`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>

Diff

 1diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme
 2index 8c700d06adb639b60d5adaef30af0857053b095f..b0a3b7b3f427a1f3fcdc153786781de814cd2c6a 100644
 3--- a/themes/agnoster.zsh-theme
 4+++ b/themes/agnoster.zsh-theme
 5@@ -106,7 +106,7 @@ prompt_git() {
 6   }
 7   local ref dirty mode repo_path
 8 
 9-  if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
10+   if [[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]]; then
11     repo_path=$(git rev-parse --git-dir 2>/dev/null)
12     dirty=$(parse_git_dirty)
13     ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git rev-parse --short HEAD 2> /dev/null)"