Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Ohmyzsh
Commits
45473c3a
Commit
45473c3a
authored
Aug 11, 2015
by
Kentaro Wada
Committed by
Marc Cornellà
Aug 16, 2015
Browse files
Fix for initial or detached status branch info
parent
30bed07e
Changes
1
Hide whitespace changes
Inline
Side-by-side
plugins/git-prompt/gitstatus.py
View file @
45473c3a
...
@@ -5,6 +5,8 @@ from __future__ import print_function
...
@@ -5,6 +5,8 @@ from __future__ import print_function
prehash
=
':'
prehash
=
':'
import
sys
import
sys
import
re
import
subprocess
from
subprocess
import
Popen
,
PIPE
from
subprocess
import
Popen
,
PIPE
...
@@ -21,8 +23,13 @@ ahead, behind = 0, 0
...
@@ -21,8 +23,13 @@ ahead, behind = 0, 0
status
=
[(
line
[
0
],
line
[
1
],
line
[
2
:])
for
line
in
stdout
.
decode
(
'utf-8'
).
splitlines
()]
status
=
[(
line
[
0
],
line
[
1
],
line
[
2
:])
for
line
in
stdout
.
decode
(
'utf-8'
).
splitlines
()]
for
st
in
status
:
for
st
in
status
:
if
st
[
0
]
==
'#'
and
st
[
1
]
==
'#'
:
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
()
branch
=
st
[
2
].
strip
()
if
branch
==
'HEAD (no branch)'
:
cmd
=
[
'git'
,
'log'
,
'-1'
,
'--format="%h"'
]
branch
=
subprocess
.
check_output
(
cmd
).
strip
().
strip
(
'"'
)
else
:
else
:
# current and remote branch info
# current and remote branch info
branch
,
rest
=
st
[
2
].
strip
().
split
(
'...'
)
branch
,
rest
=
st
[
2
].
strip
().
split
(
'...'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment