Created
June 10, 2011 08:58
-
-
Save mkwiatkowski/1018512 to your computer and use it in GitHub Desktop.
Shows commits present only in one of the two branches.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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