From b2ddfb36441596fb9793b786cf2728196146f9f2 Mon Sep 17 00:00:00 2001 From: Oliver Baumann Date: Mon, 11 Sep 2017 21:51:29 +0200 Subject: [PATCH] Parse branch-name for fresh repo 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 --- plugins/git-prompt/gitstatus.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/git-prompt/gitstatus.py b/plugins/git-prompt/gitstatus.py index a8eb8284..14d87597 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()