Commit 3c045c90765d79dce64d829837b719f16f4af2ab
- Date: Thu Apr 03 21:35:49 +0000 2008
- Committer: David A. Cuadrado (krawek@gmail.com)
- Author: David A. Cuadrado (krawek@gmail.com)
- Commit SHA1: 3c045c90765d79dce64d829837b719f16f4af2ab
- Tree SHA1: 943e481ef0291f63e4ee61cd8ac6ad780956c475
Grit::Git: Allow to use pipe (|), and do not use empty/nil arguments
Commit diff
| |   |
| 31 | 31 | # Returns String |
| 32 | 32 | def method_missing(cmd, options = {}, *args) |
| 33 | 33 | opt_args = transform_options(options) |
| 34 | | ext_args = args.map { |a| a == '--' ? a : "'#{e(a)}'" } |
| 34 | ext_args = args.map { |a| if not a.to_s.empty? then (a == '--' or a =~ /^\s*\|/) ? a : "'#{shell_escape(a)}'" end } |
| 35 | 35 | |
| 36 | 36 | call = "#{Git.git_binary} --git-dir='#{self.git_dir}' #{cmd.to_s.gsub(/_/, '-')} #{(opt_args + ext_args).join(' ')}" |
| 37 | 37 | puts call if Grit.debug |
| toggle raw diff |
--- a/lib/grit/git.rb
+++ b/lib/grit/git.rb
@@ -31,7 +31,7 @@ module Grit
# Returns String
def method_missing(cmd, options = {}, *args)
opt_args = transform_options(options)
- ext_args = args.map { |a| a == '--' ? a : "'#{e(a)}'" }
+ ext_args = args.map { |a| if not a.to_s.empty? then (a == '--' or a =~ /^\s*\|/) ? a : "'#{shell_escape(a)}'" end }
call = "#{Git.git_binary} --git-dir='#{self.git_dir}' #{cmd.to_s.gsub(/_/, '-')} #{(opt_args + ext_args).join(' ')}"
puts call if Grit.debug |