Skip to content

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

@ariasuni

Description

@ariasuni

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions