summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Baumann <baumanno@users.noreply.github.com>2018-04-30 16:25:02 +0200
committerMarc Cornellà <marc.cornella@live.com>2018-04-30 16:25:02 +0200
commit493c30954bae3da4ccd80333b807a8d37c131da8 (patch)
treed86541a5a3caec82acce56ff93d12740f4585181
parent32952ec7e8fc254e892eb1c32191d0c1901ae811 (diff)
downloadzsh-493c30954bae3da4ccd80333b807a8d37c131da8.tar.gz
zsh-493c30954bae3da4ccd80333b807a8d37c131da8.tar.bz2
zsh-493c30954bae3da4ccd80333b807a8d37c131da8.zip
Parse branch-name for fresh repo (#6302)
Inside a fresh git repo, i.e. immediately after a `git init`, usually no commit template exists yet. In this case, git renders a different status message than "Initial commit on". We should consider this message when attempting to parse out the branch name. Fixes #6301
-rw-r--r--plugins/git-prompt/gitstatus.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/plugins/git-prompt/gitstatus.py b/plugins/git-prompt/gitstatus.py
index a8eb8284b..14d875973 100644
--- a/plugins/git-prompt/gitstatus.py
+++ b/plugins/git-prompt/gitstatus.py
@@ -41,7 +41,7 @@ ahead, behind = 0, 0
status = [(line[0], line[1], line[2:]) for line in stdout.decode('utf-8').splitlines()]
for st in status:
if st[0] == '#' and st[1] == '#':
- if re.search('Initial commit on', st[2]):
+ if re.search('Initial commit on', st[2]) or re.search('No commits yet on', st[2]):
branch = st[2].split(' ')[-1]
elif re.search('no branch', st[2]): # detached status
branch = get_tagname_or_hash()