diff options
| author | Kentaro Wada <www.kentaro.wada@gmail.com> | 2015-08-11 12:04:51 +0900 | 
|---|---|---|
| committer | Marc Cornellà <marc.cornella@live.com> | 2015-08-16 23:02:17 +0200 | 
| commit | 45473c3a81410735dac7fe0a1df33ad95fd3f2e5 (patch) | |
| tree | b5c320d7670faa1f73f839db6fbf6f5e3e3005a7 /plugins | |
| parent | 30bed07e9c9480d1e563d29da5747ce427f58d8d (diff) | |
| download | zsh-45473c3a81410735dac7fe0a1df33ad95fd3f2e5.tar.gz zsh-45473c3a81410735dac7fe0a1df33ad95fd3f2e5.tar.bz2 zsh-45473c3a81410735dac7fe0a1df33ad95fd3f2e5.zip  | |
Fix for initial or detached status branch info
Diffstat (limited to 'plugins')
| -rw-r--r-- | plugins/git-prompt/gitstatus.py | 9 | 
1 files changed, 8 insertions, 1 deletions
diff --git a/plugins/git-prompt/gitstatus.py b/plugins/git-prompt/gitstatus.py index 8790f3a3c..59feadc39 100644 --- a/plugins/git-prompt/gitstatus.py +++ b/plugins/git-prompt/gitstatus.py @@ -5,6 +5,8 @@ from __future__ import print_function  prehash = ':'  import sys +import re +import subprocess  from subprocess import Popen, PIPE @@ -21,8 +23,13 @@ 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 len(st[2].strip().split('...')) == 1: +        if re.search('Initial commit on', st[2]): +            branch = st[2].split(' ')[-1] +        elif len(st[2].strip().split('...')) == 1:              branch = st[2].strip() +            if branch == 'HEAD (no branch)': +                cmd = ['git', 'log', '-1', '--format="%h"'] +                branch = subprocess.check_output(cmd).strip().strip('"')          else:              # current and remote branch info              branch, rest = st[2].strip().split('...')  | 
