Skip to content

Commit a18c079

Browse files
committed
fix IFS split on (behind n)/(ahead n)
1 parent 4f7241a commit a18c079

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

git-branch-status

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,11 @@ readonly CAHEAD=$CYELLOW
136136
readonly CBEHIND=$CRED
137137
readonly CEVEN=$CGREEN
138138
readonly CNOUPSTREAM=$CRED
139+
readonly JOIN_CHAR='_'
140+
readonly JOIN_REGEX="s/$JOIN_CHAR/ /"
139141
readonly STAR="*"
140142
readonly DELIM="|"
141-
readonly NO_UPSTREAM="(no-upstream)"
143+
readonly NO_UPSTREAM="(no${JOIN_CHAR}upstream)"
142144
readonly NO_RESULTS_MSG="Everything is synchronized"
143145

144146

@@ -180,12 +182,12 @@ do
180182
# set data for branches with upstream
181183
local_color=$CDEFAULT
182184
if (($n_behind))
183-
then behind_msg="(behind $n_behind)" ; behind_color=$CBEHIND
184-
else behind_msg="(even)" ; behind_color=$CEVEN ;
185+
then behind_msg="(behind$JOIN_CHAR$n_behind)" ; behind_color=$CBEHIND
186+
else behind_msg="(even)" ; behind_color=$CEVEN ;
185187
fi
186188
if (($n_ahead))
187-
then ahead_msg="(ahead $n_ahead)" ; ahead_color=$CAHEAD ;
188-
else ahead_msg="(even)" ; ahead_color=$CEVEN ;
189+
then ahead_msg="(ahead$JOIN_CHAR$n_ahead)" ; ahead_color=$CAHEAD ;
190+
else ahead_msg="(even)" ; ahead_color=$CEVEN ;
189191
fi
190192
remote_color=$CDEFAULT
191193
elif (($SHOW_ALL_LOCAL)) ; then
@@ -221,9 +223,9 @@ for (( result_n = 0 ; result_n < ${#local_msgs[@]} ; result_n++ ))
221223
do
222224
# fetch data
223225
local_msg=${local_msgs[$result_n]}
224-
behind_msg=${behind_msgs[$result_n]}
225-
ahead_msg=${ahead_msgs[$result_n]}
226-
remote_msg=${remote_msgs[$result_n]}
226+
behind_msg=$( echo ${behind_msgs[$result_n]} | sed "$JOIN_REGEX" )
227+
ahead_msg=$( echo ${ahead_msgs[$result_n]} | sed "$JOIN_REGEX" )
228+
remote_msg=$( echo ${remote_msgs[$result_n]} | sed "$JOIN_REGEX" )
227229
local_color="${local_colors[$result_n]}"
228230
behind_color="${behind_colors[$result_n]}"
229231
ahead_color="${ahead_colors[$result_n]}"

0 commit comments

Comments
 (0)