def run(prefix, cmd, postfix, options, args)
timeout = options.delete(:timeout) rescue nil
timeout = true if timeout.nil?
opt_args = transform_options(options)
if RUBY_PLATFORM.downcase =~ /mswin(?!ce)|mingw|bccwin/
ext_args = args.reject { |a| a.empty? }.map { |a| (a == '--' || a[0].chr == '|') ? a : "\"#{e(a)}\"" }
call = "#{prefix}#{Git.git_binary} --git-dir=\"#{self.git_dir}\" #{cmd.to_s.gsub(/_/, '-')} #{(opt_args + ext_args).join(' ')}#{e(postfix)}"
else
ext_args = args.reject { |a| a.empty? }.map { |a| (a == '--' || a[0].chr == '|') ? a : "'#{e(a)}'" }
call = "#{prefix}#{Git.git_binary} --git-dir='#{self.git_dir}' #{cmd.to_s.gsub(/_/, '-')} #{(opt_args + ext_args).join(' ')}#{e(postfix)}"
end
Grit.log(call) if Grit.debug
response, err = timeout ? sh(call) : wild_sh(call)
Grit.log(response) if Grit.debug
Grit.log(err) if Grit.debug
response
end