From: Chuck Hagenbuch Date: Thu, 26 Mar 2009 19:12:00 +0000 (-0400) Subject: track the git cli version, and make at least basic functionality work with git 1.5 X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=ee6cc834774b47c44eed8102ae21412b8e0e8ae1;p=horde.git track the git cli version, and make at least basic functionality work with git 1.5 --- diff --git a/framework/Vcs/lib/Horde/Vcs/Git.php b/framework/Vcs/lib/Horde/Vcs/Git.php index 491e72a1c..46af74ca1 100644 --- a/framework/Vcs/lib/Horde/Vcs/Git.php +++ b/framework/Vcs/lib/Horde/Vcs/Git.php @@ -55,6 +55,21 @@ class Horde_Vcs_Git extends Horde_Vcs protected $_branchlist; /** + * The git version + * + * @var string + */ + public $version; + + public function __construct($params = array()) + { + parent::__construct($params); + + $v = trim(shell_exec($this->getPath('git') . ' --version')); + $this->version = preg_replace('/[^\d\.]/', '', $v); + } + + /** * TODO */ public function isValidRevision($rev) @@ -365,9 +380,23 @@ class Horde_Vcs_File_Git extends Horde_Vcs_File parent::__construct($rep, $fl, $opts); $log_list = null; - $revs = array(); - $cmd = $rep->getCommand() . ' rev-list --branches -- ' . escapeshellarg($this->queryModulePath()) . ' 2>&1'; + if (version_compare($rep->version, '1.6.0', '>=')) { + $cmd = $rep->getCommand() . ' rev-list --branches -- ' . escapeshellarg($this->queryModulePath()) . ' 2>&1'; + } else { + $cmd = $rep->getCommand() . ' branch -v --no-abbrev'; + exec($cmd, $branch_heads); + if (stripos($branch_heads[0], 'fatal') === 0) { + throw new Horde_Vcs_Exception(implode(', ', $branch_heads)); + } + foreach ($branch_heads as &$hd) { + $line = explode(' ', substr($hd, 2)); + $hd = $line[1]; + } + + $cmd = $rep->getCommand() . ' rev-list ' . implode(' ', $branch_heads) . ' -- ' . escapeshellarg($this->queryModulePath()) . ' 2>&1'; + } + exec($cmd, $revs); if (stripos($revs[0], 'fatal') === 0) { throw new Horde_Vcs_Exception(implode(', ', $revs));