Fix, upstream should be correctly calculated with git < v1.8, fix by @celeron55
This commit is contained in:
parent
4286e4eb63
commit
7bf90d46de
9
base.sh
9
base.sh
@ -26,7 +26,7 @@ function build_prompt {
|
|||||||
just_init=true
|
just_init=true
|
||||||
else
|
else
|
||||||
upstream=$(git rev-parse --symbolic-full-name --abbrev-ref @{upstream} 2> /dev/null)
|
upstream=$(git rev-parse --symbolic-full-name --abbrev-ref @{upstream} 2> /dev/null)
|
||||||
if [ -n $upstream -a "$upstream" != "@upstream}" ]; then has_upstream=true; else has_upstream=false; fi
|
if [ -n $upstream -a "$upstream" != "@{upstream}" ]; then has_upstream=true; else has_upstream=false; fi
|
||||||
|
|
||||||
git_status=$(git status --porcelain 2> /dev/null)
|
git_status=$(git status --porcelain 2> /dev/null)
|
||||||
|
|
||||||
@ -53,9 +53,10 @@ function build_prompt {
|
|||||||
|
|
||||||
commits_diff=$(git log --pretty=oneline --topo-order --left-right ${current_commit_hash}...${upstream} 2> /dev/null)
|
commits_diff=$(git log --pretty=oneline --topo-order --left-right ${current_commit_hash}...${upstream} 2> /dev/null)
|
||||||
|
|
||||||
commits_ahead=$(git log --pretty=oneline --topo-order --left-right ${current_commit_hash}...${upstream} | grep -c "^<" )
|
if [[ $has_upstream == true ]]; then
|
||||||
commits_behind=$(git log --pretty=oneline --topo-order --left-right ${current_commit_hash}...${upstream} | grep -c "^>" )
|
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 "^>" )
|
||||||
|
fi
|
||||||
if [[ $commits_ahead -gt 0 && $commits_behind -gt 0 ]]; then
|
if [[ $commits_ahead -gt 0 && $commits_behind -gt 0 ]]; then
|
||||||
has_diverged=true
|
has_diverged=true
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user