summaryrefslogtreecommitdiffstats
path: root/powerline_gitstatus/segments.py
diff options
context:
space:
mode:
Diffstat (limited to 'powerline_gitstatus/segments.py')
-rw-r--r--powerline_gitstatus/segments.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/powerline_gitstatus/segments.py b/powerline_gitstatus/segments.py
index 81c51db..cdd0a01 100644
--- a/powerline_gitstatus/segments.py
+++ b/powerline_gitstatus/segments.py
@@ -11,9 +11,9 @@ class GitStatusSegment(Segment):
def execute(self, pl, command):
pl.debug('Executing command: %s' % ' '.join(command))
-
+
git_env = os.environ.copy()
- git_env['LC_ALL'] = 'C'
+ git_env['LC_ALL'] = 'C'
proc = Popen(command, stdout=PIPE, stderr=PIPE, env=git_env)
out, err = [item.decode('utf-8') for item in proc.communicate()]
@@ -27,13 +27,13 @@ class GitStatusSegment(Segment):
def get_base_command(self, cwd, use_dash_c):
if use_dash_c:
- return ['git', '-C', cwd]
+ return ['git', '-c', 'core.fsmonitor=', '-C', cwd]
while cwd and cwd != os.sep:
gitdir = os.path.join(cwd, '.git')
if os.path.isdir(gitdir):
- return ['git', '--git-dir=%s' % gitdir, '--work-tree=%s' % cwd]
+ return ['git', '-c', 'core.fsmonitor=', '--git-dir=%s' % gitdir, '--work-tree=%s' % cwd]
cwd = os.path.dirname(cwd)
@@ -80,10 +80,10 @@ class GitStatusSegment(Segment):
return (staged, unmerged, changed, untracked)
- def build_segments(self, formats, branch, detached, tag, behind, ahead, staged, unmerged, changed, untracked, stashed):
+ def build_segments(self, formats, branch, detached, tag, behind, ahead, staged, unmerged, changed, untracked, stashed, untracked_not_dirty):
if detached:
branch_group = 'gitstatus_branch_detached'
- elif staged or unmerged or changed or untracked:
+ elif staged or unmerged or changed or (untracked and not untracked_not_dirty):
branch_group = 'gitstatus_branch_dirty'
else:
branch_group = 'gitstatus_branch_clean'
@@ -111,7 +111,7 @@ class GitStatusSegment(Segment):
return segments
- def __call__(self, pl, segment_info, use_dash_c=True, show_tag=False, formats={}, detached_head_style='revision'):
+ def __call__(self, pl, segment_info, use_dash_c=True, show_tag=False, formats={}, detached_head_style='revision', untracked_not_dirty=False):
pl.debug('Running gitstatus %s -C' % ('with' if use_dash_c else 'without'))
cwd = segment_info['getcwd']()
@@ -160,7 +160,7 @@ class GitStatusSegment(Segment):
else:
tag = tag[0]
- return self.build_segments(formats, branch, detached, tag, behind, ahead, staged, unmerged, changed, untracked, stashed)
+ return self.build_segments(formats, branch, detached, tag, behind, ahead, staged, unmerged, changed, untracked, stashed, untracked_not_dirty)
gitstatus = with_docstring(GitStatusSegment(),
@@ -189,6 +189,10 @@ if that number is greater than zero.
Display style when in detached HEAD state. Valid values are ``revision``, which shows the current revision id, and ``ref``, which shows the closest reachable ref object.
The default is ``revision``.
+:param untracked_not_dirty:
+ Untracked files alone will not mark the git branch status as dirty.
+ False by default.
+
Divider highlight group used: ``gitstatus:divider``.
Highlight groups used: ``gitstatus_branch_detached``, ``gitstatus_branch_dirty``, ``gitstatus_branch_clean``, ``gitstatus_branch``, ``gitstatus_tag``, ``gitstatus_behind``, ``gitstatus_ahead``, ``gitstatus_staged``, ``gitstatus_unmerged``, ``gitstatus_changed``, ``gitstatus_untracked``, ``gitstatus_stashed``, ``gitstatus``.