From 5974a48fa5232a8a4ab05785e28cb5da7bdb4c4e Mon Sep 17 00:00:00 2001
From: Marco Villegas <marvil07@gmail.com>
Date: Mon, 10 Jan 2011 10:08:39 -0500
Subject: [PATCH] Avoid unnecessary calls to shell_exec().

---
 versioncontrol_git.module |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git versioncontrol_git.module versioncontrol_git.module
index 5071797..6de043e 100644
--- versioncontrol_git.module
+++ versioncontrol_git.module
@@ -82,10 +82,14 @@ function versioncontrol_git_views_api() {
  * Validate the path supplied for the git binary.
  */
 function _versioncontrol_git_binary_check_path($path) {
+  $dynamic_path = &ctools_static(__FUNCTION__);
   $errors = array();
   // Special case for using evironment $PATH to determine git executable.
   if ($path == 'git') {
-    $path = trim(shell_exec('which git'));
+    if (!isset($dynamic_path)) {
+      $dynamic_path = trim(shell_exec('which git'));
+    }
+    $path = $dynamic_path;
     if (empty($path)) {
       $errors[] = t('<code>git</code> binary was not found on the <code>$PATH</code>, try to set manually the absolute path to the git binary at %link', array('%link' => l('configuration', 'admin/settings/versioncontrol-settings')));
       return $errors;
-- 
1.7.2.3

