Merge pull request #2 from pkok/master

When no upstream is configured, the script behaves as if push.default=current
master
Martin Gondermann 13 years ago
commit 48eff2e073
  1. 36
      gitstatus.py

@ -46,27 +46,31 @@ else:
remote_name = Popen(['git','config','branch.%s.remote' % branch], stdout=PIPE).communicate()[0].strip() remote_name = Popen(['git','config','branch.%s.remote' % branch], stdout=PIPE).communicate()[0].strip()
if remote_name: if remote_name:
merge_name = Popen(['git','config','branch.%s.merge' % branch], stdout=PIPE).communicate()[0].strip() merge_name = Popen(['git','config','branch.%s.merge' % branch], stdout=PIPE).communicate()[0].strip()
if remote_name == '.': # local else:
remote_ref = merge_name remote_name = "origin"
else: merge_name = "refs/heads/%s" % branch
remote_ref = 'refs/remotes/%s/%s' % (remote_name, merge_name[11:])
revgit = Popen(['git', 'rev-list', '--left-right', '%s...HEAD' % remote_ref],stdout=PIPE, stderr=PIPE) if remote_name == '.': # local
revlist = revgit.communicate()[0] remote_ref = merge_name
if revgit.poll(): # fallback to local else:
revlist = Popen(['git', 'rev-list', '--left-right', '%s...HEAD' % merge_name],stdout=PIPE, stderr=PIPE).communicate()[0] remote_ref = 'refs/remotes/%s/%s' % (remote_name, merge_name[11:])
behead = revlist.splitlines() revgit = Popen(['git', 'rev-list', '--left-right', '%s...HEAD' % remote_ref],stdout=PIPE, stderr=PIPE)
ahead = len([x for x in behead if x[0]=='>']) revlist = revgit.communicate()[0]
behind = len(behead) - ahead if revgit.poll(): # fallback to local
if behind: revlist = Popen(['git', 'rev-list', '--left-right', '%s...HEAD' % merge_name],stdout=PIPE, stderr=PIPE).communicate()[0]
remote += '%s%s' % (symbols['behind'], behind) behead = revlist.splitlines()
if ahead: ahead = len([x for x in behead if x[0]=='>'])
remote += '%s%s' % (symbols['ahead of'], ahead) behind = len(behead) - ahead
if behind:
remote += '%s%s' % (symbols['behind'], behind)
if ahead:
remote += '%s%s' % (symbols['ahead of'], ahead)
if remote == "": if remote == "":
remote = '.' remote = '.'
out = '\n'.join([ out = '\n'.join([
str(branch), str(branch),
str(remote), str(remote),
staged, staged,
conflicts, conflicts,

Loading…
Cancel
Save