summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/redmine/mime_type.rb2
-rw-r--r--lib/redmine/scm/adapters/git_adapter.rb14
2 files changed, 9 insertions, 7 deletions
diff --git a/lib/redmine/mime_type.rb b/lib/redmine/mime_type.rb
index 57bdbcfe1..dfdfff407 100644
--- a/lib/redmine/mime_type.rb
+++ b/lib/redmine/mime_type.rb
@@ -23,7 +23,7 @@ module Redmine
'text/css' => 'css',
'text/html' => 'html,htm,xhtml',
'text/jsp' => 'jsp',
- 'text/x-c' => 'c,cpp,h',
+ 'text/x-c' => 'c,cpp,cc,h,hh',
'text/x-java' => 'java',
'text/x-javascript' => 'js',
'text/x-html-template' => 'rhtml',
diff --git a/lib/redmine/scm/adapters/git_adapter.rb b/lib/redmine/scm/adapters/git_adapter.rb
index 088f83af7..f1d076360 100644
--- a/lib/redmine/scm/adapters/git_adapter.rb
+++ b/lib/redmine/scm/adapters/git_adapter.rb
@@ -231,13 +231,15 @@ module Redmine
identifier = 'HEAD' if identifier.blank?
cmd = "#{GIT_BIN} --git-dir #{target('')} blame -l #{shell_quote identifier} -- #{shell_quote path}"
blame = Annotate.new
- shellout(cmd) do |io|
- io.each_line do |line|
- next unless line =~ /([0-9a-f]{39,40})\s\((\w*)[^\)]*\)(.*)$/
- blame.add_line($3.rstrip, Revision.new(:identifier => $1, :author => $2.strip))
- end
- end
+ 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?
+ 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))
+ end
blame
end