summaryrefslogtreecommitdiffstats
path: root/lib/redmine/scm/adapters/git_adapter.rb
diff options
context:
space:
mode:
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>2012-03-28 15:40:37 +0000
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>2012-03-28 15:40:37 +0000
commit3e11f9abfe9d55963983305b8ca71ca0a428b1cc (patch)
treee3543e51ace2732883bebc78524b5ba74ec73ec8 /lib/redmine/scm/adapters/git_adapter.rb
parentfbe959b2a8153df0da01b2320a78f6f0786e05a3 (diff)
downloadredmine-3e11f9abfe9d55963983305b8ca71ca0a428b1cc.tar.gz
redmine-3e11f9abfe9d55963983305b8ca71ca0a428b1cc.zip
scm: git: use stdin instead of command line in "git log" (#10470)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9282 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/redmine/scm/adapters/git_adapter.rb')
-rw-r--r--lib/redmine/scm/adapters/git_adapter.rb27
1 files changed, 16 insertions, 11 deletions
diff --git a/lib/redmine/scm/adapters/git_adapter.rb b/lib/redmine/scm/adapters/git_adapter.rb
index 307520faa..2264d686f 100644
--- a/lib/redmine/scm/adapters/git_adapter.rb
+++ b/lib/redmine/scm/adapters/git_adapter.rb
@@ -197,24 +197,28 @@ module Redmine
def revisions(path, identifier_from, identifier_to, options={})
revs = Revisions.new
- cmd_args = %w|log --no-color --encoding=UTF-8 --raw --date=iso --pretty=fuller --parents|
+ cmd_args = %w|log --no-color --encoding=UTF-8 --raw --date=iso --pretty=fuller --parents --stdin|
cmd_args << "--reverse" if options[:reverse]
cmd_args << "-n" << "#{options[:limit].to_i}" if options[:limit]
- from_to = ""
+ cmd_args << "--" << scm_iconv(@path_encoding, 'UTF-8', path) if path && !path.empty?
+ revisions = []
if identifier_from || identifier_to
- from_to << "#{identifier_from}.." if identifier_from
- from_to << "#{identifier_to}" if identifier_to
- cmd_args << from_to if !from_to.empty?
+ revisions << ""
+ revisions[0] << "#{identifier_from}.." if identifier_from
+ revisions[0] << "#{identifier_to}" if identifier_to
else
- cmd_args += options[:includes] unless options[:includes].blank?
+ unless options[:includes].blank?
+ revisions += options[:includes]
+ end
unless options[:excludes].blank?
- cmd_args << "--not"
- cmd_args += options[:excludes]
+ revisions += options[:excludes].map{|r| "^#{r}"}
end
end
- cmd_args << "--" << scm_iconv(@path_encoding, 'UTF-8', path) if path && !path.empty?
- git_cmd(cmd_args) do |io|
+ git_cmd(cmd_args, {:write_stdin => true}) do |io|
+ io.binmode
+ io.puts(revisions.join("\n"))
+ io.close_write
files=[]
changeset = {}
parsing_descr = 0 #0: not parsing desc or files, 1: parsing desc, 2: parsing files
@@ -383,7 +387,7 @@ module Redmine
end
end
- def git_cmd(args, &block)
+ def git_cmd(args, options = {}, &block)
repo_path = root_url || url
full_args = ['--git-dir', repo_path]
if self.class.client_version_above?([1, 7, 2])
@@ -393,6 +397,7 @@ module Redmine
full_args += args
ret = shellout(
self.class.sq_bin + ' ' + full_args.map { |e| shell_quote e.to_s }.join(' '),
+ options,
&block
)
if $? && $?.exitstatus != 0