File tree Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change 4343
4444# ## helpers ###
4545
46- function current_branch() { echo $( git rev-parse --abbrev-ref HEAD) ; }
46+ function get_refs
47+ {
48+ echo " ` git for-each-ref --format=" %(refname:short) %(upstream:short)" refs/heads 2> /dev/null` "
49+ }
50+
51+ function get_status
52+ {
53+ git rev-list --left-right ${local} ...${remote} -- 2> /dev/null
54+ }
55+
56+ function current_branch() { echo $( git rev-parse --abbrev-ref HEAD) ; }
4757
4858function set_filter_or_die
4959{
106116
107117 # parse local<->remote sync status
108118 if [ $remote ] ; then
109- status=$( git rev-list --left-right ${local} ... ${remote} -- 2> /dev/null )
119+ status=$( get_status )
110120 [ $(( $? )) -eq 0 ] || continue
111121
112122 n_ahead=$( echo $status | tr " " " \n" | grep -c ' ^<' )
141151 if [ ${# n_behind} -gt $behind_col_w ] ; then behind_col_w=${# n_behind} ; fi ;
142152 if [ ${# remote} -gt $remote_col_w ] ; then remote_col_w=${# remote} ; fi ;
143153
144- done < <( git for-each-ref --format= " %(refname:short) %(upstream:short) " refs/heads )
154+ done < <( get_refs )
145155
146156# compensate for "(ahead )" and "(behind )" to be appended
147157ahead_col_w=$(( $ahead_col_w + 8 ))
179189 printf " $local_msg$ahead_msg$behind_msg$remote_msg$end_msg \n"
180190done
181191
182- # print something if no diffs
183- if [ " $n_total_differences " == 0 ] ; then echo -e $NO_RESULTS_MSG ; fi ;
192+ # print something if no diffs (and some branches exist in this dir)
193+ if [ " $n_total_differences " == 0 -a " $( get_refs) " ]
194+ then echo -e $NO_RESULTS_MSG
195+ fi
You can’t perform that action at this time.
0 commit comments