Skip to content

Commit

Permalink
Made compatible with git 2.14 on empty repo
Browse files Browse the repository at this point in the history
  • Loading branch information
iliakan committed Aug 8, 2017
1 parent 806889d commit 1d6089e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion gitstatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ def get_stash():
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:
Expand Down Expand Up @@ -150,4 +152,3 @@ def get_stash():
Print(out.encode('utf-8'))
else:
Print(out)

4 changes: 4 additions & 0 deletions gitstatus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1d6089e

Please sign in to comment.