fix #13 The number of commits ahed and behind are correctly calculated
This commit is contained in:
parent
bcee0df296
commit
ddef73a164
10
prompt.sh
10
prompt.sh
@ -92,15 +92,9 @@ function build_prompt {
|
||||
can_fast_forward=false
|
||||
|
||||
commits_diff=$(git log --pretty=oneline --topo-order --left-right ${current_commit_hash}...${upstream} 2> /dev/null)
|
||||
commits_ahead=0
|
||||
commits_behind=0
|
||||
|
||||
if [[ $commits_diff =~ .*^\<(..) ]]; then
|
||||
commits_ahead=${#BASH_REMATCH[@]}
|
||||
fi
|
||||
if [[ $commits_diff =~ .*^\>(..) ]]; then
|
||||
commits_behind=${#BASH_REMATCH[@]}
|
||||
fi
|
||||
commits_ahead=$(git log --pretty=oneline --topo-order --left-right ${current_commit_hash}...${upstream} | grep -c "^<" )
|
||||
commits_behind=$(git log --pretty=oneline --topo-order --left-right ${current_commit_hash}...${upstream} | grep -c "^>" )
|
||||
|
||||
if [[ $commits_ahead -gt 0 && $commits_behind -gt 0 ]]; then
|
||||
has_diverged=true
|
||||
|
Loading…
Reference in New Issue
Block a user