diff --git a/share/functions/fish_git_prompt.fish b/share/functions/fish_git_prompt.fish index f461a53e4..42d236df8 100644 --- a/share/functions/fish_git_prompt.fish +++ b/share/functions/fish_git_prompt.fish @@ -247,11 +247,12 @@ function fish_git_prompt --description "Prompt function for Git" # This has to be set explicitly. if test "$dirty" = true set dirtystate (__fish_git_prompt_dirty) - if test -n "$sha" - set stagedstate (__fish_git_prompt_staged) - else - set invalidstate 1 - end + end + + if test -n "$sha" + set stagedstate (__fish_git_prompt_staged) + else + set invalidstate 1 end if set -q __fish_git_prompt_showstashstate diff --git a/tests/checks/git.fish b/tests/checks/git.fish index 43b6d8b78..2892720ce 100644 --- a/tests/checks/git.fish +++ b/tests/checks/git.fish @@ -38,7 +38,7 @@ complete -C'git add ' git checkout -b newbranch >/dev/null 2>&1 fish_git_prompt echo # the git prompt doesn't print a newline -#CHECK: (newbranch) +#CHECK: (newbranch +) set -g __fish_git_prompt_show_informative_status 1 fish_git_prompt @@ -49,10 +49,8 @@ set -e __fish_git_prompt_show_informative_status # Confirm the mode changes back fish_git_prompt echo -#CHECK: (newbranch) +#CHECK: (newbranch +) -# (for some reason stagedstate is only shown with showdirtystate?) -set -g __fish_git_prompt_showdirtystate 1 git add foo fish_git_prompt echo