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
This commit is contained in:
parent
5086bc4383
commit
c4b84ec510
|
@ -102,11 +102,12 @@ module Redmine
|
||||||
|
|
||||||
def entries(path=nil, identifier=nil)
|
def entries(path=nil, identifier=nil)
|
||||||
path ||= ''
|
path ||= ''
|
||||||
|
p = scm_iconv(@path_encoding, 'UTF-8', path)
|
||||||
entries = Entries.new
|
entries = Entries.new
|
||||||
cmd = "#{self.class.sq_bin} --git-dir #{target('')} ls-tree -l "
|
cmd_args = %w|ls-tree -l|
|
||||||
cmd << shell_quote("HEAD:" + path) if identifier.nil?
|
cmd_args << "HEAD:#{p}" if identifier.nil?
|
||||||
cmd << shell_quote(identifier + ":" + path) if identifier
|
cmd_args << "#{identifier}:#{p}" if identifier
|
||||||
shellout(cmd) do |io|
|
scm_cmd(*cmd_args) do |io|
|
||||||
io.each_line do |line|
|
io.each_line do |line|
|
||||||
e = line.chomp.to_s
|
e = line.chomp.to_s
|
||||||
if e =~ /^\d+\s+(\w+)\s+([0-9a-f]{40})\s+([0-9-]+)\t(.+)$/
|
if e =~ /^\d+\s+(\w+)\s+([0-9a-f]{40})\s+([0-9-]+)\t(.+)$/
|
||||||
|
@ -115,8 +116,10 @@ module Redmine
|
||||||
size = $3
|
size = $3
|
||||||
name = $4
|
name = $4
|
||||||
full_path = path.empty? ? name : "#{path}/#{name}"
|
full_path = path.empty? ? name : "#{path}/#{name}"
|
||||||
entries << Entry.new({:name => name,
|
n = scm_iconv('UTF-8', @path_encoding, name)
|
||||||
:path => full_path,
|
full_p = scm_iconv('UTF-8', @path_encoding, full_path)
|
||||||
|
entries << Entry.new({:name => n,
|
||||||
|
:path => full_p,
|
||||||
:kind => (type == "tree") ? 'dir' : 'file',
|
:kind => (type == "tree") ? 'dir' : 'file',
|
||||||
:size => (type == "tree") ? nil : size,
|
: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
|
||||||
|
@ -124,8 +127,9 @@ module Redmine
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return nil if $? && $?.exitstatus != 0
|
|
||||||
entries.sort_by_name
|
entries.sort_by_name
|
||||||
|
rescue ScmCommandAborted
|
||||||
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def lastrev(path, rev)
|
def lastrev(path, rev)
|
||||||
|
|
Loading…
Reference in New Issue