From 2296c23d921e7b9393b6a65aa2121ac1842112cb Mon Sep 17 00:00:00 2001 From: Ryan Tomayko Date: Thu, 9 Dec 2010 01:03:16 -0800 Subject: [PATCH] locate git_binary on PATH at boot Avoids starting a /bin/sh and /usr/bin/env process on each native command invocation, and will allow exec'ing the command directly. --- lib/grit/git.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/grit/git.rb b/lib/grit/git.rb index d5f4627..2e9ee49 100644 --- a/lib/grit/git.rb +++ b/lib/grit/git.rb @@ -37,11 +37,9 @@ module Grit attr_accessor :git_binary, :git_timeout, :git_max_size end - if RUBY_PLATFORM.downcase =~ /mswin(?!ce)|mingw|bccwin/ - self.git_binary = "git" # using search path - else - self.git_binary = "/usr/bin/env git" - end + self.git_binary = ENV['PATH'].split(':'). + map { |p| File.join(p, 'git') }. + find { |p| File.exist?(p) } self.git_timeout = 10 self.git_max_size = 5242880 # 5.megabytes