#!/usr/bin/env ruby ## git-show-merges: a simple script to show you which topic branches have ## been merged into the current branch, and which haven't. (Or, specify ## the set of merge branches you're interested in on the command line.) ## ## git-show-merges Copyright 2008 William Morgan . ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or (at ## your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You can find the GNU General Public License at: ## http://www.gnu.org/licenses/ heads = if ARGV.empty? [`git symbolic-ref HEAD`.chomp] else ARGV end.map { |r| r.gsub(/refs\/heads\//, "") } branches = `git show-ref --heads`. scan(/^\S+ refs\/heads\/(\S+)$/). map { |a| a.first } unknown = heads - branches unless unknown.empty? $stderr.puts "Unknown branch: #{unknown.first}" exit(-1) end branches -= heads heads.each do |h| merged = branches.select { |b| `git log #{h}..#{b}` == "" } unmerged = branches - merged puts "merged into #{h}:" merged.each { |b| puts " #{b}" } puts puts "not merged into #{h}: " unmerged.each { |b| puts " #{b}" } puts end