Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fish_git_prompt: git statuses aren’t displayed in the same order if $__fish_git_prompt_show_informative_status is set or not #7926

Closed
ariasuni opened this issue Apr 13, 2021 · 1 comment

Comments

@ariasuni
Copy link

ariasuni commented Apr 13, 2021

When $__fish_git_prompt_show_informative_status is not set:

if test -n "$sha"
set i (__fish_git_prompt_staged)
else
set i $___fish_git_prompt_char_invalidstate
end

if test -n "$w"
set w "$___fish_git_prompt_color_dirtystate$w$___fish_git_prompt_color_dirtystate_done"
end
if test -n "$i"
set i "$___fish_git_prompt_color_stagedstate$i$___fish_git_prompt_color_stagedstate_done"
end
if test -n "$s"
set s "$___fish_git_prompt_color_stashstate$s$___fish_git_prompt_color_stashstate_done"
end
if test -n "$u"
set u "$___fish_git_prompt_color_untrackedfiles$u$___fish_git_prompt_color_untrackedfiles_done"
end

# Formatting
set -l f "$w$i$s$u"

When $__fish_git_prompt_show_informative_status is set:

set -g ___fish_git_prompt_status_order stagedstate invalidstate dirtystate untrackedfiles stashstate

In the first case, the order is: dirty, staged OR invalid, stash, untracked
In the second case, the order is: staged, invalid, dirty, untracked, stash

I believe the second order is more logical, because git status displays: staged, invalid, dirty, untracked in this order, and then putting the stash state at the end is the only logical place.

Here’s an example of running git status in a repository:

On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

You have unmerged paths.
  (fix conflicts and run "git commit")
  (use "git merge --abort" to abort the merge)

Changes to be committed:
        modified:   src/theme/default_theme.rs

Unmerged paths:
  (use "git add <file>..." to mark resolution)
        both modified:   src/info/filetype.rs

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   Cargo.lock

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        centos7/

Note: when$__fish_git_prompt_show_informative_status is not set, I’m not able to get the __fish_git_prompt_char_invalidstate char to appear on the prompt.


fish 3.2.1

@faho
Copy link
Member

faho commented Apr 13, 2021

Yeah, makes sense. I picked the informative order, via $__fish_git_prompt_status_order (which is now an actual documented configuration knob that could also replace showdirtystate and showuntrackedfiles).

(also doing this I noticed that stagedstate wasn't printed if dirtystate wasn't supposed to be, which makes no sense)

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 10, 2021
@fish-shell fish-shell unlocked this conversation Nov 2, 2021
@floam floam added this to the fish 3.4.0 milestone Nov 2, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants