diff options
author | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2011-03-08 04:50:48 +0000 |
---|---|---|
committer | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2011-03-08 04:50:48 +0000 |
commit | c4b84ec5104e9f5bf034af9008ce7e1783639f13 (patch) | |
tree | 2efa360d81cee3b2a79268da152dcc3fc4844c55 /lib/redmine/scm/adapters/git_adapter.rb | |
parent | 5086bc4383443ee66d2362b3ed3bc735ed04bf42 (diff) | |
download | redmine-c4b84ec5104e9f5bf034af9008ce7e1783639f13.tar.gz redmine-c4b84ec5104e9f5bf034af9008ce7e1783639f13.zip |
scm: git: support path encoding in adapter entries() (#5251).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5040 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/redmine/scm/adapters/git_adapter.rb')
-rw-r--r-- | lib/redmine/scm/adapters/git_adapter.rb | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/lib/redmine/scm/adapters/git_adapter.rb b/lib/redmine/scm/adapters/git_adapter.rb index 4b12126f0..3ba0c9930 100644 --- a/lib/redmine/scm/adapters/git_adapter.rb +++ b/lib/redmine/scm/adapters/git_adapter.rb @@ -102,30 +102,34 @@ module Redmine def entries(path=nil, identifier=nil) path ||= '' + p = scm_iconv(@path_encoding, 'UTF-8', path) entries = Entries.new - cmd = "#{self.class.sq_bin} --git-dir #{target('')} ls-tree -l " - cmd << shell_quote("HEAD:" + path) if identifier.nil? - cmd << shell_quote(identifier + ":" + path) if identifier - shellout(cmd) do |io| + cmd_args = %w|ls-tree -l| + cmd_args << "HEAD:#{p}" if identifier.nil? + cmd_args << "#{identifier}:#{p}" if identifier + scm_cmd(*cmd_args) do |io| io.each_line do |line| e = line.chomp.to_s if e =~ /^\d+\s+(\w+)\s+([0-9a-f]{40})\s+([0-9-]+)\t(.+)$/ type = $1 - sha = $2 + sha = $2 size = $3 name = $4 full_path = path.empty? ? name : "#{path}/#{name}" - entries << Entry.new({:name => name, - :path => full_path, + n = scm_iconv('UTF-8', @path_encoding, name) + full_p = scm_iconv('UTF-8', @path_encoding, full_path) + entries << Entry.new({:name => n, + :path => full_p, :kind => (type == "tree") ? 'dir' : 'file', :size => (type == "tree") ? nil : size, - :lastrev => @flag_report_last_commit ? lastrev(full_path,identifier) : Revision.new + :lastrev => @flag_report_last_commit ? lastrev(full_path, identifier) : Revision.new }) unless entries.detect{|entry| entry.name == name} end end end - return nil if $? && $?.exitstatus != 0 entries.sort_by_name + rescue ScmCommandAborted + nil end def lastrev(path, rev) |