Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

parse_git_dirty() support for Git 1.6 #1654

Merged
merged 1 commit into from

2 participants

@bertag

Git 1.6 does not support the "Git status -s" option, so directories were always show up dirty on systems stuck on older versions of Git. This is a lightweight patch that tweaks the if/else logic in the parse_git_dirty() function to support for Git 1.6 while retaining support for newer versions.

@robbyrussell robbyrussell merged commit cd55560 into robbyrussell:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 11, 2013
  1. @bertag

    Tweaked parse_git_dirty() in lib/git.zsh to support proper dirty/clea…

    bertag authored
    …n parsing against both git 1.6 and git 1.7+
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 4 deletions.
  1. +7 −4 lib/git.zsh
View
11 lib/git.zsh
@@ -9,16 +9,19 @@ function git_prompt_info() {
# Checks if working tree is dirty
parse_git_dirty() {
local SUBMODULE_SYNTAX=''
+ local GIT_STATUS=''
+ local CLEAN_MESSAGE='nothing to commit (working directory clean)'
if [[ "$(git config --get oh-my-zsh.hide-status)" != "1" ]]; then
if [[ $POST_1_7_2_GIT -gt 0 ]]; then
SUBMODULE_SYNTAX="--ignore-submodules=dirty"
- fi
- if [[ -n $(git status -s ${SUBMODULE_SYNTAX} 2> /dev/null) ]]; then
+ fi
+ GIT_STATUS=$(git status -s ${SUBMODULE_SYNTAX} 2> /dev/null | tail -n1)
+ if [[ -n $GIT_STATUS && "$GIT_STATUS" != "$CLEAN_MESSAGE" ]]; then
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
else
echo "$ZSH_THEME_GIT_PROMPT_CLEAN"
- fi
- fi
+ fi
+ fi
}
# get the difference between the local and remote branches
Something went wrong with that request. Please try again.