diff --git a/gitstatus.py b/gitstatus.py index e049d08..bf1d1d9 100755 --- a/gitstatus.py +++ b/gitstatus.py @@ -89,6 +89,8 @@ for st in status: if st[0] == '#' and st[1] == '#': if re.search('Initial commit on', st[2]): branch = st[2].split(' ')[-1] + elif re.search('No commits yet on', st[2]): + branch = st[2].split(' ')[-1] elif re.search('no branch', st[2]): # detached status branch = get_tag_or_hash() elif len(st[2].strip().split('...')) == 1: @@ -150,4 +152,3 @@ if python_version == 2: Print(out.encode('utf-8')) else: Print(out) - diff --git a/gitstatus.sh b/gitstatus.sh index 713c5db..9ec99ce 100755 --- a/gitstatus.sh +++ b/gitstatus.sh @@ -72,6 +72,10 @@ if [[ "$branch" == *"Initial commit on"* ]]; then IFS=" " read -ra fields <<< "$branch" branch="${fields[3]}" remote="_NO_REMOTE_TRACKING_" +elif [[ "$branch" == *"No commits yet on"* ]]; then + IFS=" " read -ra fields <<< "$branch" + branch="${fields[4]}" + remote="_NO_REMOTE_TRACKING_" elif [[ "$branch" == *"no branch"* ]]; then tag=$( git describe --tags --exact-match ) if [[ -n "$tag" ]]; then