[packages/rpm-build-tools] bash-prompt: skip comparing with remote if upstream not defined for branch
glen
glen at pld-linux.org
Sun Nov 20 19:10:58 CET 2016
commit de250abab0e0933cf3749de519ccc54d698e7232
Author: Elan Ruusamäe <glen at delfi.ee>
Date: Sun Nov 20 20:10:37 2016 +0200
bash-prompt: skip comparing with remote if upstream not defined for branch
bash-prompt.sh | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
---
diff --git a/bash-prompt.sh b/bash-prompt.sh
index 467e4b3..959fd02 100644
--- a/bash-prompt.sh
+++ b/bash-prompt.sh
@@ -55,18 +55,20 @@ __bash_parse_git_branch() {
fi
# http://stackoverflow.com/a/3278427
- local=$(git rev-parse @)
- remote=$(git rev-parse '@{u}')
- base=$(git merge-base @ '@{u}')
-
- if [ $local = $remote ]; then
- remote=""
- elif [ $local = $base ]; then
- remote="${YELLOW}↓"
- elif [ $remote = $base ]; then
- remote="${YELLOW}↑"
- else
- remote="${YELLOW}↕"
+ remote=$(git rev-parse '@{u}' 2>/dev/null)
+ if [[ -n "$remote" ]]; then
+ local=$(git rev-parse @)
+ base=$(git merge-base @ '@{u}')
+
+ if [[ $local = $remote ]]; then
+ remote=""
+ elif [[ $local = $base ]]; then
+ remote="${YELLOW}↓"
+ elif [[ $remote = $base ]]; then
+ remote="${YELLOW}↑"
+ else
+ remote="${YELLOW}↕"
+ fi
fi
echo " (${branch})${remote}${state}"
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/rpm-build-tools.git/commitdiff/de250abab0e0933cf3749de519ccc54d698e7232
More information about the pld-cvs-commit
mailing list