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

make git_prompt_status more accurate #2054

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

foobacca
Copy link

The git_prompt_status function only matched some of the possible output
from git status --porcelain --branch - this commit should match pretty
much the whole range, defined by the git status man page as:

X          Y     Meaning
-------------------------------------------------
          [MD]   not updated
M        [ MD]   updated in index
A        [ MD]   added to index
D         [ M]   deleted from index
R        [ MD]   renamed in index
C        [ MD]   copied in index
[MARC]           index and work tree matches
[ MARC]     M    work tree changed since index
[ MARC]     D    deleted in work tree
-------------------------------------------------
D           D    unmerged, both deleted
A           U    unmerged, added by us
U           D    unmerged, deleted by them
U           A    unmerged, added by them
D           U    unmerged, deleted by us
A           A    unmerged, both added
U           U    unmerged, both modified
-------------------------------------------------
?           ?    untracked
!           !    ignored
-------------------------------------------------

Note that with the current variables it doesn't really distinguish
between changes in the staging area and changes in the working directory

  • to do that would require a lot more ZSH_THEME_GIT_PROMPT_XYZ variables.

Also git status no longer seems to use the text "diverged" - instead it
says both "ahead" and "behind" if you have diverged. The second commit
fixes that logic.

The git_prompt_status function only matched some of the possible output
from `git status --porcelain --branch` - this commit should match pretty
much the whole range, defined by the git status man page as:

    X          Y     Meaning
    -------------------------------------------------
              [MD]   not updated
    M        [ MD]   updated in index
    A        [ MD]   added to index
    D         [ M]   deleted from index
    R        [ MD]   renamed in index
    C        [ MD]   copied in index
    [MARC]           index and work tree matches
    [ MARC]     M    work tree changed since index
    [ MARC]     D    deleted in work tree
    -------------------------------------------------
    D           D    unmerged, both deleted
    A           U    unmerged, added by us
    U           D    unmerged, deleted by them
    U           A    unmerged, added by them
    D           U    unmerged, deleted by us
    A           A    unmerged, both added
    U           U    unmerged, both modified
    -------------------------------------------------
    ?           ?    untracked
    !           !    ignored
    -------------------------------------------------

Note that with the current variables it doesn't really distinguish
between changes in the staging area and changes in the working directory
- to do that would require a lot more ZSH_THEME_GIT_PROMPT_XYZ variables.
git status no longer seems to use the text "diverged" - instead it says
both "ahead" and "behind" if you have diverged.
apjanke added a commit to apjanke/ohmyzsh that referenced this pull request Apr 1, 2015
@mcornella mcornella added Area: core Issue or PR related to core parts of the project Status: conflicts Pull Request that has conflicts with the master branch labels Mar 24, 2019
@lochel lochel mentioned this pull request Oct 7, 2022
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: core Issue or PR related to core parts of the project Status: conflicts Pull Request that has conflicts with the master branch
Projects
Status: Backlog
Development

Successfully merging this pull request may close these issues.

None yet

2 participants