Created
March 23, 2012 12:04
-
-
Save antirez/2170066 to your computer and use it in GitHub Desktop.
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/tclsh8.5 | |
# | |
# Usage: unmerged branch1 branch2 | |
proc getlog branch { | |
lrange [split [exec git log $branch --oneline] "\n"] 0 100 | |
} | |
proc diff {title c1 c2} { | |
puts "\n$title" | |
foreach commit1 $c1 { | |
set found 0 | |
set sha [lindex [split $commit1] 0] | |
set msg [join [lrange [split $commit1] 1 end]] | |
foreach commit2 $c2 { | |
set msg2 [join [lrange [split $commit2] 1 end]] | |
if {$msg eq $msg2} { | |
set found 1 | |
break | |
} | |
} | |
if {!$found} { | |
puts "$commit1" | |
} | |
} | |
} | |
if {[llength $::argv] != 2} { | |
puts stderr "Usage: unmerged branch1 branch2" | |
exit 1 | |
} | |
set branch1 [lindex $::argv 0] | |
set branch2 [lindex $::argv 1] | |
set c1 [getlog $branch1] | |
set c2 [getlog $branch2] | |
diff "Only in $branch1" [lrange $c1 0 50] $c2 | |
diff "Only in $branch2" [lrange $c2 0 50] $c1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I arrived here while looking to solve a slightly different problem: I'd like to see the branches (and commits therein) that aren't merged with master (or another branch that I specify). I found this 'git-unmerged' script very useful for solving that: http://mutuallyhuman.com/blog/2009/07/02/finding-unmerged-commits-with-git-unmerged
Posting here in case others find themselves in a similar situation.