From b989b7f324cf7c2d04eca941916395b4a05252b7 Mon Sep 17 00:00:00 2001 From: oGre Date: Fri, 25 Sep 2015 12:30:29 +0200 Subject: [PATCH] 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_"