From 56af5d0702d888c011e6fe9cffe63faa94a07bdd Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Tue, 13 Apr 2021 18:57:06 +0200 Subject: [PATCH] Revert "git prompt: Show stagedstate without dirtystate" After further thinking, showing this now, by default, without a nice way to turn it off isn't great. This reverts commit 573fed7798d5660e694b0f01f186e4141275b73d. --- share/functions/fish_git_prompt.fish | 13 +++++++------ tests/checks/git.fish | 6 ++++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/share/functions/fish_git_prompt.fish b/share/functions/fish_git_prompt.fish index 6e7bacc01..a51963304 100644 --- a/share/functions/fish_git_prompt.fish +++ b/share/functions/fish_git_prompt.fish @@ -222,7 +222,9 @@ function fish_git_prompt --description "Prompt function for Git" and set dirty true end # If we don't print these, there is no need to compute them. + # Note: For now, staged and dirty are coupled. contains dirtystate $__fish_git_prompt_status_order + or contains stagedstate $__fish_git_prompt_status_order or set dirty false set -l untracked (command git config --bool bash.showUntrackedFiles) @@ -252,12 +254,11 @@ 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) - end - - if test -n "$sha" - set stagedstate (__fish_git_prompt_staged) - else - set invalidstate 1 + if test -n "$sha" + set stagedstate (__fish_git_prompt_staged) + else + set invalidstate 1 + end end if set -q __fish_git_prompt_showstashstate diff --git a/tests/checks/git.fish b/tests/checks/git.fish index 2892720ce..43b6d8b78 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,8 +49,10 @@ 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