Skip to content

Instantly share code, notes, and snippets.

@mkwiatkowski
Created June 10, 2011 08:58
Show Gist options
  • Save mkwiatkowski/1018512 to your computer and use it in GitHub Desktop.
Save mkwiatkowski/1018512 to your computer and use it in GitHub Desktop.
Shows commits present only in one of the two branches.
#!/usr/bin/python
# Shows commits present only in one of the two branches.
import commands
import sys
def commits_in_branch(branch):
status, output = commands.getstatusoutput("git log --no-color --pretty=oneline %s" % branch)
return set(output.splitlines())
def print_diff(br1name, br1, br2name, br2):
print "Commits in %s, but not in %s:" % (br1name, br2name)
print '\n'.join(br1 - br2)
if len(sys.argv) < 3:
print "usage:\n git-diff-branches branch1 branch2"
else:
br1name, br2name = sys.argv[1:3]
br1 = commits_in_branch(br1name)
br2 = commits_in_branch(br2name)
print_diff(br1name, br1, br2name, br2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment