mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-04-26 14:01:13 -03:00
Silence math errors in git prompt
It's not ideal since we can't get the real result so we just assume it's "0". That triggers the easier path, which still might display the wrong thing, but we have to pick something. Possible fix for #3321.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user