From 85bb05cccb8a568104dbe106e10b8e22f7d9d70d Mon Sep 17 00:00:00 2001 From: Bernhard Furtmueller Date: Mon, 23 Nov 2009 09:00:09 +0000 Subject: [PATCH] switched git blame to use the porcelain format (-p) --- lib/redmine/scm/adapters/git_adapter.rb | 19 +++++++++++++++---- 1 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/redmine/scm/adapters/git_adapter.rb b/lib/redmine/scm/adapters/git_adapter.rb index 14e1674..4b43e73 100644 --- a/lib/redmine/scm/adapters/git_adapter.rb +++ b/lib/redmine/scm/adapters/git_adapter.rb @@ -230,18 +230,29 @@ module Redmine def annotate(path, identifier=nil) identifier = 'HEAD' if identifier.blank? - cmd = "#{GIT_BIN} --git-dir #{target('')} blame -l #{shell_quote identifier} -- #{shell_quote path}" + cmd = "#{GIT_BIN} --git-dir #{target('')} blame -p #{shell_quote identifier} -- #{shell_quote path}" blame = Annotate.new content = nil shellout(cmd) { |io| io.binmode; content = io.read } return nil if $? && $?.exitstatus != 0 # git annotates binary files return nil if content.is_binary_data? + ident = "" + src = "" + auth = Hash.new content.split("\n").each do |line| - next unless line =~ /([0-9a-f]{39,40})\s\((\w*)[^\)]*\)(.*)/ - blame.add_line($3.rstrip, Revision.new(:identifier => $1, :author => $2.strip)) + if line =~ /^([0-9a-f]{39,40})\s.*/ + ident = $1 + end + if line =~ /^author (.*)/ + auth[ident] = $1.strip + end + if line =~ /^\t(.*)/ + src = $1 + blame.add_line(src, Revision.new(:identifier => ident, :author => auth[ident])) + end end - blame + blame unless blame.empty? end def cat(path, identifier=nil) -- 1.6.5.2