| ... | ... |
@@ -4,15 +4,21 @@ function git_prompt_info() {
|
| 4 | 4 |
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
|
| 5 | 5 |
} |
| 6 | 6 |
|
| 7 |
+ |
|
| 7 | 8 |
# Checks if working tree is dirty |
| 8 | 9 |
parse_git_dirty() {
|
| 9 |
- if [[ -n $(git status -s --ignore-submodules=dirty 2> /dev/null) ]]; then |
|
| 10 |
+ local SUBMODULE_SYNTAX='' |
|
| 11 |
+ if [[ $POST_1_7_2_GIT -gt 0 ]]; then |
|
| 12 |
+ SUBMODULE_SYNTAX="--ignore-submodules=dirty" |
|
| 13 |
+ fi |
|
| 14 |
+ if [[ -n $(git status -s ${SUBMODULE_SYNTAX} 2> /dev/null) ]]; then
|
|
| 10 | 15 |
echo "$ZSH_THEME_GIT_PROMPT_DIRTY" |
| 11 | 16 |
else |
| 12 | 17 |
echo "$ZSH_THEME_GIT_PROMPT_CLEAN" |
| 13 | 18 |
fi |
| 14 | 19 |
} |
| 15 | 20 |
|
| 21 |
+ |
|
| 16 | 22 |
# Checks if there are commits ahead from remote |
| 17 | 23 |
function git_prompt_ahead() {
|
| 18 | 24 |
if $(echo "$(git log origin/$(current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then |
| ... | ... |
@@ -61,4 +67,30 @@ git_prompt_status() {
|
| 61 | 61 |
STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS" |
| 62 | 62 |
fi |
| 63 | 63 |
echo $STATUS |
| 64 |
-} |
|
| 65 | 64 |
\ No newline at end of file |
| 65 |
+} |
|
| 66 |
+ |
|
| 67 |
+#this is unlikely to change so make it all statically assigned |
|
| 68 |
+POST_1_7_2_GIT=$(git_compare_version "1.7.2") |
|
| 69 |
+#clean up the namespace slightly by removing the checker function |
|
| 70 |
+unset -f git_compare_version() |
|
| 71 |
+ |
|
| 72 |
+#compare the provided version of git to the version installed and on path |
|
| 73 |
+#prints 1 if input version <= installed version |
|
| 74 |
+#prints -1 otherwise |
|
| 75 |
+function git_compare_version() {
|
|
| 76 |
+ local INPUT_GIT_VERSION=$1; |
|
| 77 |
+ local INSTALLED_GIT_VERSION |
|
| 78 |
+ INPUT_GIT_VERSION=(${(s/./)INPUT_GIT_VERSION});
|
|
| 79 |
+ INSTALLED_GIT_VERSION=($(git --version)); |
|
| 80 |
+ INSTALLED_GIT_VERSION=(${(s/./)INSTALLED_GIT_VERSION[3]});
|
|
| 81 |
+ |
|
| 82 |
+ for i in {1..3}; do
|
|
| 83 |
+ if [[ $INSTALLED_GIT_VERSION[$i] -lt $INPUT_GIT_VERSION[$i] ]]; then |
|
| 84 |
+ echo -1 |
|
| 85 |
+ return 0 |
|
| 86 |
+ fi |
|
| 87 |
+ done |
|
| 88 |
+ echo 1 |
|
| 89 |
+} |
|
| 90 |
+ |
|
| 91 |
+ |