Cache git exe version
Cache git exe version

--- a/include/git/GitExe.class.php
+++ b/include/git/GitExe.class.php
@@ -53,6 +53,24 @@
 	 * @access protected
 	 */
 	protected $binary;
+	
+	/**
+	 * version
+	 *
+	 * Stores the binary version internally
+	 *
+	 * @access protected
+	 */
+	protected $version;
+
+	/**
+	 * versionRead
+	 *
+	 * Stores whether the version has been read
+	 *
+	 * @access protected
+	 */
+	protected $versionRead = false;
 
 	/**
 	 * GetInstance
@@ -188,12 +206,30 @@
 	 */
 	public function GetVersion()
 	{
+		if (!$this->versionRead)
+			$this->ReadVersion();
+
+		return $this->version;
+	}
+
+	/**
+	 * ReadVersion
+	 *
+	 * Reads the git version
+	 *
+	 * @access protected
+	 */
+	protected function ReadVersion()
+	{
+		$this->versionRead = true;
+
+		$this->version = '';
+
 		$versionCommand = $this->binary . ' --version';
 		$ret = trim(shell_exec($versionCommand));
 		if (preg_match('/^git version ([0-9\.]+)$/i', $ret, $regs)) {
-			return $regs[1];
-		}
-		return '';
+			$this->version = $regs[1];
+		}
 	}
 
 	/**

comments