mirror of
https://github.com/meineerde/redmine.git
synced 2026-04-03 22:41:39 +00:00
Use shell_quote and --git-dir for args passed to git
the cd #{target('')} approach does not work on Windows
All unit tests pass
git-svn-id: http://redmine.rubyforge.org/svn/branches/work@1218 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
e8e64d2de2
commit
ff6ed900fc
@ -27,8 +27,8 @@ module Redmine
|
|||||||
|
|
||||||
# Get the revision of a particuliar file
|
# Get the revision of a particuliar file
|
||||||
def get_rev (rev,path)
|
def get_rev (rev,path)
|
||||||
cmd="cd #{target('')} && git show #{rev} -- #{path}" if rev!='latest'
|
cmd="git --git-dir #{target('')} show #{shell_quote rev} -- #{shell_quote path}" if rev!='latest' and (! rev.nil?)
|
||||||
cmd="cd #{target('')} && git log -1 master -- #{path}" if
|
cmd="git --git-dir #{target('')} log -1 master -- #{shell_quote path}" if
|
||||||
rev=='latest' or rev.nil?
|
rev=='latest' or rev.nil?
|
||||||
rev=[]
|
rev=[]
|
||||||
i=0
|
i=0
|
||||||
@ -106,8 +106,9 @@ module Redmine
|
|||||||
def entries(path=nil, identifier=nil)
|
def entries(path=nil, identifier=nil)
|
||||||
path ||= ''
|
path ||= ''
|
||||||
entries = Entries.new
|
entries = Entries.new
|
||||||
cmd = "cd #{target('')} && #{GIT_BIN} ls-tree -l HEAD:#{path}" if identifier.nil?
|
cmd = "#{GIT_BIN} --git-dir #{target('')} ls-tree -l "
|
||||||
cmd = "cd #{target('')} && #{GIT_BIN} ls-tree -l #{identifier}:#{path}" if identifier
|
cmd << shell_quote("HEAD:" + path) if identifier.nil?
|
||||||
|
cmd << shell_quote(identifier + ":" + path) if identifier
|
||||||
shellout(cmd) do |io|
|
shellout(cmd) do |io|
|
||||||
io.each_line do |line|
|
io.each_line do |line|
|
||||||
e = line.chomp.to_s
|
e = line.chomp.to_s
|
||||||
@ -140,10 +141,10 @@ module Redmine
|
|||||||
|
|
||||||
def revisions(path, identifier_from, identifier_to, options={})
|
def revisions(path, identifier_from, identifier_to, options={})
|
||||||
revisions = Revisions.new
|
revisions = Revisions.new
|
||||||
cmd = "cd #{target('')} && #{GIT_BIN} log --raw "
|
cmd = "#{GIT_BIN} --git-dir #{target('')} log --raw "
|
||||||
cmd << " -n #{options[:limit].to_i}" if (!options.nil?) && options[:limit]
|
cmd << " -n #{options[:limit].to_i} " if (!options.nil?) && options[:limit]
|
||||||
cmd << " #{identifier_from}.. " if identifier_from
|
cmd << " #{shell_quote(identifier_from + '..')} " if identifier_from
|
||||||
cmd << " #{identifier_to} " if identifier_to
|
cmd << " #{shell_quote identifier_to} " if identifier_to
|
||||||
#cmd << " HEAD " if !identifier_to
|
#cmd << " HEAD " if !identifier_to
|
||||||
shellout(cmd) do |io|
|
shellout(cmd) do |io|
|
||||||
files=[]
|
files=[]
|
||||||
@ -212,9 +213,9 @@ module Redmine
|
|||||||
identifier_to = nil
|
identifier_to = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
cmd = "cd #{target('')} && #{GIT_BIN} show #{identifier_from}" if identifier_to.nil?
|
cmd = "#{GIT_BIN} --git-dir #{target('')} show #{shell_quote identifier_from}" if identifier_to.nil?
|
||||||
cmd = "cd #{target('')} && #{GIT_BIN} diff #{identifier_to} #{identifier_from}" if !identifier_to.nil?
|
cmd = "#{GIT_BIN} --git-dir #{target('')} diff #{shell_quote identifier_to} #{shell_quote identifier_from}" if !identifier_to.nil?
|
||||||
cmd << " -- #{path}" unless path.empty?
|
cmd << " -- #{shell_quote path}" unless path.empty?
|
||||||
diff = []
|
diff = []
|
||||||
shellout(cmd) do |io|
|
shellout(cmd) do |io|
|
||||||
io.each_line do |line|
|
io.each_line do |line|
|
||||||
@ -227,7 +228,7 @@ module Redmine
|
|||||||
|
|
||||||
def annotate(path, identifier=nil)
|
def annotate(path, identifier=nil)
|
||||||
identifier = 'HEAD' if identifier.blank?
|
identifier = 'HEAD' if identifier.blank?
|
||||||
cmd = "cd #{target('')} && #{GIT_BIN} blame -l #{identifier} -- #{path}"
|
cmd = "#{GIT_BIN} --git-dir #{target('')} blame -l #{shell_quote identifier} -- #{shell_quote path}"
|
||||||
blame = Annotate.new
|
blame = Annotate.new
|
||||||
shellout(cmd) do |io|
|
shellout(cmd) do |io|
|
||||||
io.each_line do |line|
|
io.each_line do |line|
|
||||||
@ -243,7 +244,7 @@ module Redmine
|
|||||||
if identifier.nil?
|
if identifier.nil?
|
||||||
identifier = 'HEAD'
|
identifier = 'HEAD'
|
||||||
end
|
end
|
||||||
cmd = "cd #{target('')} && #{GIT_BIN} show #{identifier}:#{path}"
|
cmd = "#{GIT_BIN} --git-dir #{target('')} show #{shell_quote(identifier + ':' + path)}"
|
||||||
cat = nil
|
cat = nil
|
||||||
shellout(cmd) do |io|
|
shellout(cmd) do |io|
|
||||||
io.binmode
|
io.binmode
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user