Commit 107f92ab authored by Toshi MARUYAMA's avatar Toshi MARUYAMA Committed by Eric Davis

scm: git: support path encoding in adapter blame (#5251).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5041 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent efa1d583
...@@ -274,14 +274,14 @@ module Redmine ...@@ -274,14 +274,14 @@ module Redmine
rescue ScmCommandAborted rescue ScmCommandAborted
nil nil
end end
def annotate(path, identifier=nil) def annotate(path, identifier=nil)
identifier = 'HEAD' if identifier.blank? identifier = 'HEAD' if identifier.blank?
cmd = "#{self.class.sq_bin} --git-dir #{target('')} blame -p #{shell_quote identifier} -- #{shell_quote path}" cmd_args = %w|blame|
cmd_args << "-p" << identifier << "--" << scm_iconv(@path_encoding, 'UTF-8', path)
blame = Annotate.new blame = Annotate.new
content = nil content = nil
shellout(cmd) { |io| io.binmode; content = io.read } scm_cmd(*cmd_args) { |io| io.binmode; content = io.read }
return nil if $? && $?.exitstatus != 0
# git annotates binary files # git annotates binary files
return nil if content.is_binary_data? return nil if content.is_binary_data?
identifier = '' identifier = ''
...@@ -293,12 +293,16 @@ module Redmine ...@@ -293,12 +293,16 @@ module Redmine
elsif line =~ /^author (.+)/ elsif line =~ /^author (.+)/
authors_by_commit[identifier] = $1.strip authors_by_commit[identifier] = $1.strip
elsif line =~ /^\t(.*)/ elsif line =~ /^\t(.*)/
blame.add_line($1, Revision.new(:identifier => identifier, :author => authors_by_commit[identifier])) blame.add_line($1, Revision.new(
:identifier => identifier,
:author => authors_by_commit[identifier]))
identifier = '' identifier = ''
author = '' author = ''
end end
end end
blame blame
rescue ScmCommandAborted
nil
end end
def cat(path, identifier=nil) def cat(path, identifier=nil)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment