old_contents: import re
  import subprocess
  
  def get_git_status():
      has_pending_commits = True
      has_untracked_files = False
      origin_position = ""
      output = subprocess.Popen(['git', 'status', '--ignore-submodules'],
              env={"LANG": "C", "HOME": os.getenv("HOME")}, stdout=subprocess.PIPE).communicate()[0]
      for line in output.split('\n'):
          origin_status = re.findall(
              r"Your branch is (ahead|behind).*?(\d+) comm", line)
          diverged_status = re.findall(r"and have (\d+) and (\d+) different commits each", line)
          if origin_status:
              origin_position = " %d" % int(origin_status[0][1])
              if origin_status[0][0] == 'behind':
                  origin_position += u'\u21E3'
              if origin_status[0][0] == 'ahead':
                  origin_position += u'\u21E1'
          if diverged_status:
              origin_position = " %d%c %d%c" % (int(diverged_status[0][0]), u'\u21E1', int(diverged_status[0][1]), u'\u21E3')
  
          if line.find('nothing to commit') >= 0:
              has_pending_commits = False
          if line.find('Untracked files') >= 0:
              has_untracked_files = True
      return has_pending_commits, has_untracked_files, origin_position
  
  
  def add_git_segment():
      # See http://git-blame.blogspot.com/2013/06/checking-current-branch-programatically.html
      p = subprocess.Popen(['git', 'symbolic-ref', '-q', 'HEAD'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
      out, err = p.communicate()
  
      if 'Not a git repo' in err:
          return
  
      if out:
          branch = out[len('refs/heads/'):].rstrip()
      else:
          branch = '(Detached)'
  
      has_pending_commits, has_untracked_files, origin_position = get_git_status()
      branch += origin_position
      if has_untracked_files:
          branch += ' +'
  
      bg = Color.REPO_CLEAN_BG
      fg = Color.REPO_CLEAN_FG
      if has_pending_commits:
          bg = Color.REPO_DIRTY_BG
          fg = Color.REPO_DIRTY_FG
  
      powerline.append(' %s ' % branch, fg, bg)
  
  try:
      add_git_segment()
  except OSError:
      pass
  except subprocess.CalledProcessError:
      pass
  
new_contents: import re
  import subprocess
  
  def get_git_status():
      has_pending_commits = True
      has_untracked_files = False
      origin_position = ""
      output = subprocess.Popen(['git', 'status', '--ignore-submodules'],
              env={"LANG": "C", "HOME": os.getenv("HOME")}, stdout=subprocess.PIPE).communicate()[0]
      for line in output.split('\n'):
          origin_status = re.findall(
              r"Your branch is (ahead|behind).*?(\d+) comm", line)
          diverged_status = re.findall(r"and have (\d+) and (\d+) different commits each", line)
          if origin_status:
              origin_position = " %d" % int(origin_status[0][1])
              if origin_status[0][0] == 'behind':
                  origin_position += u'\u21E3'
              if origin_status[0][0] == 'ahead':
                  origin_position += u'\u21E1'
          if diverged_status:
              origin_position = " %d%c %d%c" % (int(diverged_status[0][0]), u'\u21E1', int(diverged_status[0][1]), u'\u21E3')
  
          if line.find('nothing to commit') >= 0:
              has_pending_commits = False
          if line.find('Untracked files') >= 0:
              has_untracked_files = True
      return has_pending_commits, has_untracked_files, origin_position
  
  
  def add_git_segment():
      # See http://git-blame.blogspot.com/2013/06/checking-current-branch-programatically.html
      p = subprocess.Popen(['git', 'symbolic-ref', '-q', 'HEAD'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
      out, err = p.communicate()
  
      if 'Not a git repo' in err:
          return
  
      branch = u'\ue0a0 '
      if out:
          branch += out[len('refs/heads/'):].rstrip()
      else:
          branch += '(Detached)'
  
      has_pending_commits, has_untracked_files, origin_position = get_git_status()
      branch += origin_position
      if has_untracked_files:
          branch += u' \u271A'
  
      bg = Color.REPO_CLEAN_BG
      fg = Color.REPO_CLEAN_FG
      if has_pending_commits:
          bg = Color.REPO_DIRTY_BG
          fg = Color.REPO_DIRTY_FG
          branch += u' \u2718'
      else:
          branch += u' \u2714'
  
  
      powerline.append(' %s ' % branch, fg, bg)
  
  try:
      add_git_segment()
  except OSError:
      pass
  except subprocess.CalledProcessError:
      pass
  
subject: Add symbols for branch, has_untracked_files, has_pending_commits and clean