[packages/rpm-build-tools] bash-prompt: skip if configured remote is not fetched

glen glen at pld-linux.org
Sun Nov 20 19:50:21 CET 2016


commit 48b09da4df04238e5f6660ddab4b949a2e540f72
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Sun Nov 20 20:49:58 2016 +0200

    bash-prompt: skip if configured remote is not fetched

 bash-prompt.sh | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/bash-prompt.sh b/bash-prompt.sh
index 959fd02..5eec276 100644
--- a/bash-prompt.sh
+++ b/bash-prompt.sh
@@ -45,7 +45,7 @@ __bash_parse_git_branch() {
 	# not in git dir. return early
 	git rev-parse --git-dir &> /dev/null || return
 
-	local state remote branch
+	local state remote branch base local
 
 	# without branch, nothing is shown; don't bother further
 	branch=$(git symbolic-ref --short HEAD 2>/dev/null) || return
@@ -56,9 +56,9 @@ __bash_parse_git_branch() {
 
 	# http://stackoverflow.com/a/3278427
 	remote=$(git rev-parse '@{u}' 2>/dev/null)
-	if [[ -n "$remote" ]]; then
+	base=$(git merge-base @ '@{u}' 2>/dev/null)
+	if [[ -n "$remote" && -n "$base" ]]; then
 		local=$(git rev-parse @)
-		base=$(git merge-base @ '@{u}')
 
 		if [[ $local = $remote ]]; then
 			remote=""
@@ -69,6 +69,8 @@ __bash_parse_git_branch() {
 		else
 			remote="${YELLOW}↕"
 		fi
+	else
+		remote=""
 	fi
 
 	echo " (${branch})${remote}${state}"
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/rpm-build-tools.git/commitdiff/48b09da4df04238e5f6660ddab4b949a2e540f72



More information about the pld-cvs-commit mailing list