mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-01-31 22:22:02 +08:00
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:
parent
f45e16e59d
commit
661ea41861
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user