642ae64bc50f93739ca280e8dcb1d6dbb5932f58
- Author
- Brice Dutheil <brice.dutheil@gmail.com>
- Committer
- Brice Dutheil <brice.dutheil@gmail.com>
- Date
Message
Inline `parse_svn` to avoid leaky state
As noted in review, `in_svn` is not properly reset to false. This is better anyway to not leak state.
Diff
1diff --git a/plugins/svn-fast-info/svn-fast-info.plugin.zsh b/plugins/svn-fast-info/svn-fast-info.plugin.zsh
2index 1027bcac27adffdbe85762d4a604c6701ce3637a..e75f2159904fd5981b84f2cecff0619b3694e17e 100644
3--- a/plugins/svn-fast-info/svn-fast-info.plugin.zsh
4+++ b/plugins/svn-fast-info/svn-fast-info.plugin.zsh
5@@ -9,18 +9,14 @@
6 #
7 # *** IMPORTANT *** DO NO USE with the simple svn plugin, this plugin acts as a replacement of it.
8
9-function parse_svn() {
10+function svn_prompt_info() {
11 info=$(svn info 2>&1) || return; # capture stdout and stdout
12- in_svn=true
13+ in_svn=true
14 repo_need_upgrade="$(svn_repo_need_upgrade $info)"
15- svn_branch_name="$(svn_get_branch_name $info)"
16- svn_dirty="$(svn_dirty_choose)"
17- svn_repo_name="$(svn_get_repo_name $info)"
18- svn_rev="$(svn_get_revision $info)"
19-}
20-
21-function svn_prompt_info() {
22- eval parse_svn
23+ svn_branch_name="$(svn_get_branch_name $info)"
24+ svn_dirty="$(svn_dirty_choose)"
25+ svn_repo_name="$(svn_get_repo_name $info)"
26+ svn_rev="$(svn_get_revision $info)"
27
28 if [ ! -z $repo_need_upgrade ]; then
29 echo $ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_PREFIX$ZSH_PROMPT_BASE_COLOR\
30@@ -28,13 +24,13 @@ $repo_need_upgrade\
31 $ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_SUFFIX$ZSH_PROMPT_BASE_COLOR
32 fi
33
34- if [[ ${in_svn} == true && -z $repo_need_upgrade ]]; then
35- echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_PREFIX\
36+ if [[ ${in_svn} == true && -z $repo_need_upgrade ]]; then
37+ echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_PREFIX\
38 $ZSH_THEME_REPO_NAME_COLOR${svn_branch_name}\
39 $ZSH_PROMPT_BASE_COLOR${svn_dirty}\
40 $ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_SUFFIX\
41 $ZSH_PROMPT_BASE_COLOR"
42- fi
43+ fi
44 }
45
46
47@@ -47,24 +43,24 @@ function svn_repo_need_upgrade() {
48 function svn_get_branch_name() {
49 info=$1
50 [ -z "${info}" ] && info=$(svn info 2> /dev/null)
51- echo $info | grep '^URL:' | egrep -o '(tags|branches)/[^/]+|trunk' | egrep -o '[^/]+$' | read SVN_URL
52- echo $SVN_URL
53+ echo $info | grep '^URL:' | egrep -o '(tags|branches)/[^/]+|trunk' | egrep -o '[^/]+$' | read SVN_URL
54+ echo $SVN_URL
55 }
56
57 function svn_get_repo_name() {
58 info=$1
59 [ -z "${info}" ] && info=$(svn info 2> /dev/null)
60- echo $info | sed -n 's/Repository\ Root:\ .*\///p' | read SVN_ROOT
61- echo $info | sed -n "s/URL:\ .*$SVN_ROOT\///p"
62+ echo $info | sed -n 's/Repository\ Root:\ .*\///p' | read SVN_ROOT
63+ echo $info | sed -n "s/URL:\ .*$SVN_ROOT\///p"
64 }
65
66 function svn_get_revision() {
67 info=$1
68 [ -z "${info}" ] && info=$(svn info 2> /dev/null)
69- echo $info 2> /dev/null | sed -n s/Revision:\ //p
70+ echo $info 2> /dev/null | sed -n s/Revision:\ //p
71 }
72
73 function svn_dirty_choose() {
74- svn status | grep -E '^\s*[ACDIM!?L]' > /dev/null 2>/dev/null && echo $ZSH_THEME_SVN_PROMPT_DIRTY && return
75- echo $ZSH_THEME_SVN_PROMPT_CLEAN
76+ svn status | grep -E '^\s*[ACDIM!?L]' > /dev/null 2>/dev/null && echo $ZSH_THEME_SVN_PROMPT_DIRTY && return
77+ echo $ZSH_THEME_SVN_PROMPT_CLEAN
78 }