From b989b7f324cf7c2d04eca941916395b4a05252b7 Mon Sep 17 00:00:00 2001 From: oGre Date: Fri, 25 Sep 2015 12:30:29 +0200 Subject: [PATCH 1/2] Able to parse tag names when on tag --- gitstatus.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/gitstatus.sh b/gitstatus.sh index a7b9c65..fc48cf7 100755 --- a/gitstatus.sh +++ b/gitstatus.sh @@ -56,18 +56,16 @@ remote= IFS="." read -ra line <<< "${branch_line/\#\# }" branch="${line[0]}" -if [[ -z "$branch" ]]; then +if [[ "$branch" == *"Initial commit on"* ]]; then + IFS=" " read -ra branch_line <<< "$branch" + branch=${branch_line[-1]} +elif [[ "$branch" == *"no branch"* ]]; then tag=$( git describe --exact-match ) if [[ -n "$tag" ]]; then branch="$tag" else branch="_PREHASH_$( git rev-parse --short HEAD )" fi -elif [[ "$branch" == *"Initial commit on"* ]]; then - IFS=" " read -ra branch_line <<< "$branch" - branch=${branch_line[-1]} -elif [[ "$branch" == *"no branch"* ]]; then - branch="_PREHASH_$( git rev-parse --short HEAD )" else if [[ "${#line[@]}" -eq 1 ]]; then remote="_NO_REMOTE_TRACKING_" From c5cac48f4d85c012a76861450067019db518c4f1 Mon Sep 17 00:00:00 2001 From: oGre Date: Fri, 25 Sep 2015 12:59:48 +0200 Subject: [PATCH 2/2] Initial commit on is always a local state - set no remote tracking --- gitstatus.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/gitstatus.sh b/gitstatus.sh index fc48cf7..7782e62 100755 --- a/gitstatus.sh +++ b/gitstatus.sh @@ -59,6 +59,7 @@ branch="${line[0]}" if [[ "$branch" == *"Initial commit on"* ]]; then IFS=" " read -ra branch_line <<< "$branch" branch=${branch_line[-1]} + remote="_NO_REMOTE_TRACKING_" elif [[ "$branch" == *"no branch"* ]]; then tag=$( git describe --exact-match ) if [[ -n "$tag" ]]; then