-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-show-merges
More file actions
executable file
·49 lines (42 loc) · 1.49 KB
/
git-show-merges
File metadata and controls
executable file
·49 lines (42 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/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 <wmorgan-git-wt-add@masanjin.net>.
## 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