Signed-off-by: Felipe Contreras <felipe.contreras@xxxxxxxxx> --- contrib/related/git-related | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/contrib/related/git-related b/contrib/related/git-related index 702836a..90ec3aa 100755 --- a/contrib/related/git-related +++ b/contrib/related/git-related @@ -8,7 +8,7 @@ $min_percent = 5 begin OptionParser.new do |opts| opts.program_name = 'git cc-cmd' - opts.banner = 'usage: git cc-cmd [options] <file>' + opts.banner = 'usage: git cc-cmd [options] <files>' opts.on('-p', '--min-percent N', Integer, 'Minium percentage of role participation') do |v| $min_percent = v @@ -61,6 +61,7 @@ class Commits def initialize() @items = {} + @main_commits = {} end def size @@ -91,24 +92,27 @@ class Commits p.each do |line| if line =~ /^(\h{40})/ id = $1 - @items[id] = Commit.new(id) + @items[id] = Commit.new(id) if not @main_commits.include?(id) end end end end - def from_patch(file) + def from_patches(files) source = nil - from = nil - File.open(file) do |f| - f.each do |line| - case line - when /^From (\h+) (.+)$/ - from = $1 - when /^---\s+(\S+)/ - source = $1 != '/dev/null' ? $1[2..-1] : nil - when /^@@\s-(\d+),(\d+)/ - get_blame(source, $1, $2, from) + files.each do |file| + from = nil + File.open(file) do |f| + f.each do |line| + case line + when /^From (\h+) (.+)$/ + from = $1 + @main_commits[from] = true + when /^---\s+(\S+)/ + source = $1 != '/dev/null' ? $1[2..-1] : nil + when /^@@\s-(\d+),(\d+)/ + get_blame(source, $1, $2, from) + end end end end @@ -116,10 +120,8 @@ class Commits end -exit 1 if ARGV.size != 1 - commits = Commits.new -commits.from_patch(ARGV[0]) +commits.from_patches(ARGV) commits.import # hash of hashes -- 1.8.2.1 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html