diff --git a/share/functions/__fish_git_prompt.fish b/share/functions/__fish_git_prompt.fish index 9a5aa7b5f..827c9c48f 100644 --- a/share/functions/__fish_git_prompt.fish +++ b/share/functions/__fish_git_prompt.fish @@ -475,14 +475,16 @@ function __fish_git_prompt_informative_status set -l changedFiles (command git diff --name-status | cut -c 1-2) set -l stagedFiles (command git diff --staged --name-status | cut -c 1-2) - set -l dirtystate (math (count $changedFiles) - (count (echo $changedFiles | grep "U"))) + set -l dirtystate (math (count $changedFiles) - (count (echo $changedFiles | grep "U")) ^/dev/null) set -l invalidstate (count (echo $stagedFiles | grep "U")) - set -l stagedstate (math (count $stagedFiles) - $invalidstate) + set -l stagedstate (math (count $stagedFiles) - $invalidstate ^/dev/null) set -l untrackedfiles (command git ls-files --others --exclude-standard | wc -l | string trim) set -l info - if [ (math $dirtystate + $invalidstate + $stagedstate + $untrackedfiles) = 0 ] + # If `math` fails for some reason, assume the state is clean - it's the simpler path + set -l state (math $dirtystate + $invalidstate + $stagedstate + $untrackedfiles ^/dev/null) + if test -z "$state"; or test "$state" = 0 set info $___fish_git_prompt_color_cleanstate$___fish_git_prompt_char_cleanstate$___fish_git_prompt_color_cleanstate_done else for i in $___fish_git_prompt_status_order