fixed asterisk display for modified repos in git prior to 1.7.2
Diff
1diff --git a/lib/git.zsh b/lib/git.zsh
2index 4d1634e8bc52d0e71721c88e9017cbdc2cc2018b..c46aa608dc49ca2b0acb7ce53d24e78475dbf122 100644
3--- a/lib/git.zsh
4+++ b/lib/git.zsh
5@@ -4,15 +4,21 @@ function git_prompt_info() {
6 echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
7 }
8 9+
10 # Checks if working tree is dirty
11 parse_git_dirty() {
12- if [[ -n $(git status -s --ignore-submodules=dirty 2> /dev/null) ]]; then
13+ local SUBMODULE_SYNTAX=''
14+ if [[ PRE_1_7_2_GIT -gt 0 ]]; then
15+ SUBMODULE_SYNTAX="--ignore-submodules=dirty"
16+ fi
17+ if [[ -n $(git status -s ${SUBMODULE_SYNTAX} 2> /dev/null) ]]; then
18 echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
19 else
20 echo "$ZSH_THEME_GIT_PROMPT_CLEAN"
21 fi
22 }
2324+
25 # Checks if there are commits ahead from remote
26 function git_prompt_ahead() {
27 if $(echo "$(git log origin/$(current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then
28@@ -61,4 +67,30 @@ git_prompt_status() {
29 STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS"
30 fi
31 echo $STATUS
32-}
33+}
34+
35+#this is unlikely to change so make it all statically assigned
36+PRE_1_7_2_GIT=$(git_compare_version "1.7.2")
37+#clean up the namespace slightly by removing the checker function
38+unset -f git_compare_version()
39+
40+#compare the provided version of git to the version installed and on path
41+#prints 1 if input version <= installed version
42+#prints -1 otherwise
43+function git_compare_version() {
44+ local INPUT_GIT_VERSION=$1;
45+ local INSTALLED_GIT_VERSION
46+ INPUT_GIT_VERSION=(${(s/./)INPUT_GIT_VERSION});
47+ INSTALLED_GIT_VERSION=($(git --version));
48+ INSTALLED_GIT_VERSION=(${(s/./)INSTALLED_GIT_VERSION[3]});
49+
50+ for i in {1..3}; do
51+ if [[ $INSTALLED_GIT_VERSION[$i] -lt $INPUT_GIT_VERSION[$i] ]]; then
52+ echo -1
53+ return 0
54+ fi
55+ done
56+ echo 1
57+}
58+
59+