Remove unused diff code
Remove unused diff code

--- a/include/git/DiffExe.class.php
+++ /dev/null
@@ -1,260 +1,1 @@
-<?php
-/**
- * GitPHP Diff Exe
- *
- * Diff executable class
- *
- * @author Christopher Han <xiphux@gmail.com>
- * @copyright Copyright (c) 2010 Christopher Han
- * @package GitPHP
- * @subpackage Git
- */
 
-/**
- * DiffExe class
- *
- * Class to handle working with the diff executable
- */
-class GitPHP_DiffExe
-{
-	
-	/**
-	 * binary
-	 *
-	 * Stores the binary path internally
-	 *
-	 * @access protected
-	 */
-	protected $binary;
-
-	/**
-	 * unified
-	 *
-	 * Stores whether diff creates unified patches
-	 *
-	 * @access protected
-	 */
-	protected $unified = true;
-
-	/**
-	 * showFunction
-	 *
-	 * Stores whether to show the function each change is in
-	 *
-	 * @access protected
-	 */
-	protected $showFunction = true;
-
-	/**
-	 * __construct
-	 *
-	 * Constructor
-	 *
-	 * @access public
-	 */
-	public function __construct()
-	{
-		$binary = GitPHP_Config::GetInstance()->GetValue('diffbin');
-		if (empty($binary)) {
-			$this->binary = GitPHP_DiffExe::DefaultBinary();
-		} else {
-			$this->binary = $binary;
-		}
-
-	}
-
-	/**
-	 * GetBinary
-	 *
-	 * Gets the binary for this executable
-	 *
-	 * @return string binary
-	 * @access public
-	 */
-	public function GetBinary()
-	{
-		return $this->binary;
-	}
-
-	/**
-	 * GetUnified
-	 *
-	 * Gets whether diff is running in unified mode
-	 *
-	 * @access public
-	 * @return mixed boolean or number of context lines
-	 */
-	public function GetUnified()
-	{
-		return $this->unified;
-	}
-
-	/**
-	 * SetUnified
-	 *
-	 * Sets whether this diff is running in unified mode
-	 *
-	 * @access public
-	 * @param mixed $unified true or false, or number of context lines
-	 */
-	public function SetUnified($unified)
-	{
-		$this->unified = $unified;
-	}
-
-	/**
-	 * GetShowFunction
-	 *
-	 * Gets whether this diff is showing the function
-	 *
-	 * @access public
-	 * @return boolean true if showing function
-	 */
-	public function GetShowFunction()
-	{
-		return $this->showFunction;
-	}
-
-	/**
-	 * SetShowFunction
-	 *
-	 * Sets whether this diff is showing the function
-	 *
-	 * @access public
-	 * @param boolean $show true to show
-	 */
-	public function SetShowFunction($show)
-	{
-		$this->showFunction = $show;
-	}
-
-	/**
-	 * Execute
-	 *
-	 * Runs diff
-	 *
-	 * @access public
-	 * @param string $fromFile source file
-	 * @param string $fromName source file display name
-	 * @param string $toFile destination file
-	 * @param string $toName destination file display name
-	 * @return string diff output
-	 */
-	public function Execute($fromFile = null, $fromName = null, $toFile = null, $toName = null)
-	{
-		if (empty($fromFile) && empty($toFile)) {
-			return '';
-		}
-
-		if (empty($fromFile)) {
-			$fromFile = '/dev/null';
-		}
-
-		if (empty($toFile)) {
-			$toFile = '/dev/null';
-		}
-
-		$args = array();
-		if ($this->unified) {
-			if (is_numeric($this->unified)) {
-				$args[] = '-U';
-				$args[] = $this->unified;
-			} else {
-				$args[] = '-u';
-			}
-
-			$args[] = '-L';
-			if (empty($fromName)) {
-				$args[] = '"' . $fromFile . '"';
-			} else {
-				$args[] = '"' . $fromName . '"';
-			}
-
-			$args[] = '-L';
-			if (empty($toName)) {
-				$args[] = '"' . $toFile . '"';
-			} else {
-				$args[] = '"' . $toName . '"';
-			}
-		}
-		if ($this->showFunction) {
-			$args[] = '-p';
-		}
-
-		$args[] = $fromFile;
-		$args[] = $toFile;
-
-		return shell_exec($this->binary . ' ' . implode(' ', $args));
-	}
-
-	/**
-	 * Valid
-	 *
-	 * Tests if this executable is valid
-	 *
-	 * @access public
-	 * @return boolean true if valid
-	 */
-	public function Valid()
-	{
-		if (empty($this->binary))
-			return false;
-
-		$code = 0;
-		$out = exec($this->binary . ' --version', $tmp, $code);
-
-		return $code == 0;
-	}
-
-	/**
-	 * Diff
-	 *
-	 * Convenience function to run diff with the default settings
-	 * and immediately discard the object
-	 *
-	 * @access public
-	 * @static
-	 * @param string $fromFile source file
-	 * @param string $fromName source file display name
-	 * @param string $toFile destination file
-	 * @param string $toName destination file display name
-	 * @return string diff output
-	 */
-	public static function Diff($fromFile = null, $fromName = null, $toFile = null, $toName = null)
-	{
-		$obj = new GitPHP_DiffExe();
-		$ret = $obj->Execute($fromFile, $fromName, $toFile, $toName);
-		unset($obj);
-		return $ret;
-	}
-
-	/**
-	 * DefaultBinary
-	 *
-	 * Gets the default binary for the platform
-	 *
-	 * @access public
-	 * @static
-	 * @return string binary
-	 */
-	public static function DefaultBinary()
-	{
-		if (GitPHP_Util::IsWindows()) {
-			// windows
-
-			if (GitPHP_Util::Is64Bit()) {
-				// match x86_64 and x64 (64 bit)
-				// C:\Program Files (x86)\Git\bin\diff.exe
-				return 'C:\\Progra~2\\Git\\bin\\diff.exe';
-			} else {
-				// 32 bit
-				// C:\Program Files\Git\bin\diff.exe
-				return 'C:\\Progra~1\\Git\\bin\\diff.exe';
-			}
-		} else {
-			// *nix, just use PATH
-			return 'diff';
-		}
-	}
-}
-

--- a/include/git/GitExe.class.php
+++ b/include/git/GitExe.class.php
@@ -25,7 +25,6 @@
 define('GIT_NAME_REV','name-rev');
 define('GIT_FOR_EACH_REF','for-each-ref');
 define('GIT_CONFIG','config');
-define('GIT_DIFF','diff');
 
 /**
  * Git Executable class

--- a/include/git/TmpDir.class.php
+++ /dev/null
@@ -1,245 +1,1 @@
-<?php
-/**
- * GitPHP Tmp Dir
- *
- * Temporary directory class
- *
- * @author Christopher Han <xiphux@gmail.com>
- * @copyright Copyright (c) 2010 Christopher Han
- * @package GitPHP
- * @subpackage Git
- */
 
-/**
- * TmpDir class
- *
- * Class to handle managing files in a temporary directory
- *
- * @author Christopher Han <xiphux@gmail.com>
- * @copyright Copyright (c) 2010 Christopher Han
- * @package GitPHP
- * @subpackage Git
- */
-class GitPHP_TmpDir
-{
-	
-	/**
-	 * instance
-	 *
-	 * Stores the singleton instance
-	 *
-	 * @access protected
-	 * @static
-	 */
-	protected static $instance;
-
-	/**
-	 * dir
-	 *
-	 * Stores the directory
-	 *
-	 * @access protected
-	 */
-	protected $dir = null;
-
-	/**
-	 * files
-	 *
-	 * Stores a list of files in this tmpdir
-	 *
-	 * @access protected
-	 */
-	protected $files = array();
-
-	/**
-	 * GetInstance
-	 *
-	 * Returns the singleton instance
-	 *
-	 * @access public
-	 * @static
-	 * @return mixed instance of tmpdir class
-	 */
-	public static function GetInstance()
-	{
-		if (!self::$instance) {
-			self::$instance = new GitPHP_TmpDir();
-		}
-		return self::$instance;
-	}
-
-	/**
-	 * SystemTmpDir
-	 *
-	 * Gets the system defined temporary directory
-	 *
-	 * @access public
-	 * @static
-	 * @return string temp dir
-	 */
-	public static function SystemTmpDir()
-	{
-		$tmpdir = '';
-
-		if (function_exists('sys_get_temp_dir')) {
-			$tmpdir = sys_get_temp_dir();
-		}
-
-		if (empty($tmpdir)) {
-			$tmpdir = getenv('TMP');
-		}
-
-		if (empty($tmpdir)) {
-			$tmpdir = getenv('TEMP');
-		}
-
-		if (empty($tmpdir)) {
-			$tmpdir = getenv('TMPDIR');
-		}
-
-		if (empty($tmpdir)) {
-			$tmpfile = tempnam(__FILE__, '');
-			if (file_exists($tmpfile)) {
-				unlink($tmpfile);
-				$tmpdir = dirname($temp);
-			}
-		}
-
-		if (empty($tmpdir)) {
-			// ultimate default - should never get this far
-			if (GitPHP_Util::IsWindows()) {
-				$tmpdir = 'C:\\Windows\\Temp';
-			} else {
-				$tmpdir = '/tmp';
-			}
-		}
-
-		return GitPHP_Util::AddSlash(realpath($tmpdir));
-	}
-
-	/**
-	 * __construct
-	 *
-	 * Constructor
-	 *
-	 * @access public
-	 */
-	public function __construct()
-	{
-		$this->dir = GitPHP_Util::AddSlash(GitPHP_Config::GetInstance()->GetValue('gittmp'));
-
-		if (empty($this->dir)) {
-			$this->dir = GitPHP_TmpDir::SystemTmpDir();
-		}
-
-		if (empty($this->dir)) {
-			throw new Exception(__('No tmpdir defined'));
-		}
-
-		if (file_exists($this->dir)) {
-			if (is_dir($this->dir)) {
-				if (!is_writeable($this->dir)) {
-					throw new Exception(sprintf(__('Specified tmpdir %1$s is not writable'), $this->dir));
-				}
-			} else {
-				throw new Exception(sprintf(__('Specified tmpdir %1$s is not a directory'), $this->dir));
-			}
-		} else if (!mkdir($this->dir, 0700)) {
-			throw new Exception(sprintf(__('Could not create tmpdir %1$s'), $this->dir));
-		}
-	}
-
-	/**
-	 * __destruct
-	 *
-	 * Destructor
-	 *
-	 * @access public
-	 */
-	public function __destruct()
-	{
-		$this->Cleanup();
-	}
-
-	/**
-	 * GetDir
-	 *
-	 * Gets the temp dir
-	 *
-	 * @return string temp dir
-	 */
-	public function GetDir()
-	{
-		return $this->dir;
-	}
-
-	/**
-	 * SetDir
-	 *
-	 * Sets the temp dir
-	 *
-	 * @param string $dir new temp dir
-	 */
-	public function SetDir($dir)
-	{
-		$this->Cleanup();
-		$this->dir = $dir;
-	}
-
-	/**
-	 * AddFile
-	 *
-	 * Adds a file to the temp dir
-	 *
-	 * @param string $filename file name
-	 * @param string $content file content
-	 */
-	public function AddFile($filename, $content)
-	{
-		if (empty($filename)) {
-			return;
-		}
-
-		file_put_contents($this->dir . $filename, $content);
-
-		if (!in_array($filename, $this->files)) {
-			$this->files[] = $filename;
-		}
-	}
-
-	/**
-	 * RemoveFile
-	 *
-	 * Removes a file from the temp dir
-	 *
-	 * @param string $filename file name
-	 */
-	public function RemoveFile($filename)
-	{
-		if (empty($filename)) {
-			return;
-		}
-
-		unlink($this->dir . $filename);
-
-		$idx = array_search($filename, $this->files);
-		if ($idx !== false) {
-			unset($this->files[$idx]);
-		}
-	}
-
-	/**
-	 * Cleanup
-	 *
-	 * Cleans up any temporary files
-	 */
-	public function Cleanup()
-	{
-		if (!empty($this->dir) && (count($this->files) > 0)) {
-			foreach ($this->files as $file) {
-				$this->RemoveFile($file);
-			}
-		}
-	}
-}
-

file:a/index.php -> file:b/index.php
--- a/index.php
+++ b/index.php
@@ -58,7 +58,6 @@
 
 // Test these executables early
 require_once(GITPHP_GITOBJECTDIR . 'GitExe.class.php');
-require_once(GITPHP_GITOBJECTDIR . 'DiffExe.class.php');
 
 date_default_timezone_set('UTC');
 
@@ -139,12 +138,6 @@
 	if (!$exe->Valid()) {
 		throw new GitPHP_MessageException(sprintf(__('Could not run the git executable "%1$s".  You may need to set the "%2$s" config value.'), $exe->GetBinary(), 'gitbin'), true, 500);
 	}
-	if (!function_exists('xdiff_string_diff')) {
-		$exe = new GitPHP_DiffExe();
-		if (!$exe->Valid()) {
-			throw new GitPHP_MessageException(sprintf(__('Could not run the diff executable "%1$s".  You may need to set the "%2$s" config value.'), $exe->GetBinary(), 'diffbin'), true, 500);
-		}
-	}
 	unset($exe);
 
 	/*

comments