From 0f17558dfebcbf71c46dc7f5fbca5ea70970797a Mon Sep 17 00:00:00 2001 From: Denis Lehmann Date: Wed, 28 Feb 2024 22:33:29 +0100 Subject: [PATCH] show missing upstream branches --- gis | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/gis b/gis index a36edfd..8f586e6 100755 --- a/gis +++ b/gis @@ -197,8 +197,12 @@ for dir in "${git_dirs[@]}"; do # Get status remote_status_keys="" + has_upstream=true while read -r status; do - if [[ "$status" =~ ^\#\#.*\[(.*)\] ]]; then + if [[ "$status" =~ ^\#\#\ (.*) ]] && [ "$(git remote | wc -l)" -gt 0 ]; then + [[ "${BASH_REMATCH[1]}" != *"..."* ]] && has_upstream=false + fi + if [[ "$status" =~ ^\#\#.*\ \[(.*)\] ]]; then [[ "${BASH_REMATCH[1]}" == *"ahead"* ]] && [[ "${BASH_REMATCH[1]}" == *"behind"* ]] && remote_status_keys="⇕" && continue [[ "${BASH_REMATCH[1]}" == *"ahead"* ]] && remote_status_keys="⇡" && continue [[ "${BASH_REMATCH[1]}" == *"behind"* ]] && remote_status_keys="⇣" && continue @@ -235,6 +239,9 @@ for dir in "${git_dirs[@]}"; do num_additional_branches=$(( num_additional_branches - 1 )) output="${output};${text_bold}${text_yellow}${current_branch}${text_reset} (${origin_head}${text_reset})" fi + if [ "$has_upstream" == false ]; then + output="${output} (no upstream)" + fi if [[ $num_additional_branches -gt 0 ]]; then output="${output} (+${num_additional_branches})" fi