diff --git a/share/functions/fish_git_prompt.fish b/share/functions/fish_git_prompt.fish index 555120c81..cdd2ab798 100644 --- a/share/functions/fish_git_prompt.fish +++ b/share/functions/fish_git_prompt.fish @@ -269,9 +269,9 @@ function fish_git_prompt --description "Prompt function for Git" test "$untracked" = true; and set opt -unormal set -l stat (command git -c core.fsmonitor= status --porcelain -z --ignored=no $opt | string split0) - set dirtystate (string match -qr '^.?M' -- $stat; and echo 1) + set dirtystate (string match -qr '^.[ACDMR]' -- $stat; and echo 1) if test -n "$sha" - set stagedstate (string match -qr '^[^? ]' -- $stat; and echo 1) + set stagedstate (string match -qr '^[ACDMR].' -- $stat; and echo 1) else set invalidstate 1 end diff --git a/tests/checks/git.fish b/tests/checks/git.fish index 2e426000b..ad2500891 100644 --- a/tests/checks/git.fish +++ b/tests/checks/git.fish @@ -85,6 +85,26 @@ fish_git_prompt echo #CHECK: (newbranch %) +set -e __fish_git_prompt_showuntrackedfiles +set -e __fish_git_prompt_status_order + +git -c user.email=banana@example.com -c user.name=banana commit -m foo >/dev/null +fish_git_prompt +echo +#CHECK: (newbranch) + +echo "test" > foo +fish_git_prompt +echo +#CHECK: (newbranch *) + +git add foo +fish_git_prompt +echo +#CHECK: (newbranch +) + + + # Turn on everything and verify we correctly ignore sus config files. set -g __fish_git_prompt_status_order stagedstate invalidstate dirtystate untrackedfiles stashstate set -g __fish_git_prompt_showdirtystate 1