0f2b24c1b8bd488cbaba713ae8e9a63b4df6d2d9

Author
Robby Russell <robby@planetargon.com>
Committer
Robby Russell <robby@planetargon.com>
Date

Message

Merge pull request #1887 from tgkokk/git-slow-fix

Fixed slow behavior when using GitHub wrappers

Diff

 1diff --git a/lib/git.zsh b/lib/git.zsh
 2index c4b5b5d62e71dfdd218b3ee97b2b1798bae11736..df0fcedbb939bc52c98906fb303a824c1ad00f1b 100644
 3--- a/lib/git.zsh
 4+++ b/lib/git.zsh
 5@@ -1,7 +1,7 @@
 6 # get the name of the branch we are on
 7 function git_prompt_info() {
 8-  ref=$(git symbolic-ref HEAD 2> /dev/null) || \
 9-  ref=$(git rev-parse --short HEAD 2> /dev/null) || return
10+  ref=$(command git symbolic-ref HEAD 2> /dev/null) || \
11+  ref=$(command git rev-parse --short HEAD 2> /dev/null) || return
12   echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
13 }
14 
15@@ -11,14 +11,14 @@ parse_git_dirty() {
16   local SUBMODULE_SYNTAX=''
17   local GIT_STATUS=''
18   local CLEAN_MESSAGE='nothing to commit (working directory clean)'
19-  if [[ "$(git config --get oh-my-zsh.hide-status)" != "1" ]]; then
20+  if [[ "$(command git config --get oh-my-zsh.hide-status)" != "1" ]]; then
21     if [[ $POST_1_7_2_GIT -gt 0 ]]; then
22           SUBMODULE_SYNTAX="--ignore-submodules=dirty"
23     fi
24     if [[ "$DISABLE_UNTRACKED_FILES_DIRTY" == "true" ]]; then
25-        GIT_STATUS=$(git status -s ${SUBMODULE_SYNTAX} -uno 2> /dev/null | tail -n1)
26+        GIT_STATUS=$(command git status -s ${SUBMODULE_SYNTAX} -uno 2> /dev/null | tail -n1)
27     else
28-        GIT_STATUS=$(git status -s ${SUBMODULE_SYNTAX} 2> /dev/null | tail -n1)
29+        GIT_STATUS=$(command git status -s ${SUBMODULE_SYNTAX} 2> /dev/null | tail -n1)
30     fi
31     if [[ -n $GIT_STATUS ]]; then
32       echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
33@@ -32,10 +32,10 @@ parse_git_dirty() {
34 
35 # get the difference between the local and remote branches
36 git_remote_status() {
37-    remote=${$(git rev-parse --verify ${hook_com[branch]}@{upstream} --symbolic-full-name 2>/dev/null)/refs\/remotes\/}
38+    remote=${$(command git rev-parse --verify ${hook_com[branch]}@{upstream} --symbolic-full-name 2>/dev/null)/refs\/remotes\/}
39     if [[ -n ${remote} ]] ; then
40-        ahead=$(git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l)
41-        behind=$(git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)
42+        ahead=$(command git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l)
43+        behind=$(command git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)
44 
45         if [ $ahead -eq 0 ] && [ $behind -gt 0 ]
46         then
47@@ -52,24 +52,24 @@ git_remote_status() {
48 
49 # Checks if there are commits ahead from remote
50 function git_prompt_ahead() {
51-  if $(echo "$(git log origin/$(current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then
52+  if $(echo "$(command git log origin/$(current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then
53     echo "$ZSH_THEME_GIT_PROMPT_AHEAD"
54   fi
55 }
56 
57 # Formats prompt string for current git commit short SHA
58 function git_prompt_short_sha() {
59-  SHA=$(git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
60+  SHA=$(command git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
61 }
62 
63 # Formats prompt string for current git commit long SHA
64 function git_prompt_long_sha() {
65-  SHA=$(git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
66+  SHA=$(command git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
67 }
68 
69 # Get the status of the working tree
70 git_prompt_status() {
71-  INDEX=$(git status --porcelain -b 2> /dev/null)
72+  INDEX=$(command git status --porcelain -b 2> /dev/null)
73   STATUS=""
74   if $(echo "$INDEX" | grep -E '^\?\? ' &> /dev/null); then
75     STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS"
76@@ -96,7 +96,7 @@ git_prompt_status() {
77   elif $(echo "$INDEX" | grep '^AD ' &> /dev/null); then
78     STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS"
79   fi
80-  if $(git rev-parse --verify refs/stash >/dev/null 2>&1); then
81+  if $(command git rev-parse --verify refs/stash >/dev/null 2>&1); then
82     STATUS="$ZSH_THEME_GIT_PROMPT_STASHED$STATUS"
83   fi
84   if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then
85@@ -121,7 +121,7 @@ function git_compare_version() {
86   local INPUT_GIT_VERSION=$1;
87   local INSTALLED_GIT_VERSION
88   INPUT_GIT_VERSION=(${(s/./)INPUT_GIT_VERSION});
89-  INSTALLED_GIT_VERSION=($(git --version 2>/dev/null));
90+  INSTALLED_GIT_VERSION=($(command git --version 2>/dev/null));
91   INSTALLED_GIT_VERSION=(${(s/./)INSTALLED_GIT_VERSION[3]});
92 
93   for i in {1..3}; do