fish_git_prompt: Use "dirty"/"staged" regex like informative

When switching this to use `git status`, I neglected to use the
correct definition of what a "dirty" and a "staged" change is.

So this now showed already staged files still as "dirty".

Fixes #8986
This commit is contained in:
Fabian Homborg 2022-06-01 17:08:33 +02:00
parent f45e16e59d
commit 661ea41861
2 changed files with 22 additions and 2 deletions

View File

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

View File

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