From: Michael M Slusarz Date: Wed, 21 Jan 2009 22:58:17 +0000 (-0700) Subject: Use escapeshellarg(); initial branch code. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=9cade686e90d626ab13c7b31d8a7d7cc4d5e877a;p=horde.git Use escapeshellarg(); initial branch code. --- diff --git a/framework/Vcs/lib/Horde/Vcs/Git.php b/framework/Vcs/lib/Horde/Vcs/Git.php index 1b03db78b..c0a63b444 100644 --- a/framework/Vcs/lib/Horde/Vcs/Git.php +++ b/framework/Vcs/lib/Horde/Vcs/Git.php @@ -21,6 +21,14 @@ class Horde_Vcs_Git extends Horde_Vcs protected $_patchsets = true; /** + * Does driver support branches? + * + * @var boolean + */ + /* @TODO */ + protected $_branches = false; + + /** * Constructor. * * @param array $params Any parameter the class expects. @@ -220,7 +228,7 @@ class Horde_Vcs_Diff_Git extends Horde_Vcs_Diff // TODO: add options for $hr options - however these may not // be compatible with some diffs. - $command = $rep->getCommand() . " diff -M -C $options --no-color $rev1..$rev2 -- \"" . $file->queryModulePath() . '" 2>&1'; + $command = $rep->getCommand() . " diff -M -C $options --no-color $rev1..$rev2 -- " . escapeshellarg($file->queryModulePath()) . ' 2>&1'; exec($command, $diff, $retval); return $diff; @@ -248,7 +256,7 @@ class Horde_Vcs_Diff_Git extends Horde_Vcs_Diff private function _getRevisionRange($rep, $file, $r1, $r2) { - $cmd = $rep->getCommand() . ' rev-list ' . $r1 . '..' . $r2 . ' -- "' . $file->queryModulePath() . '"'; + $cmd = $rep->getCommand() . ' rev-list ' . $r1 . '..' . $r2 . ' -- ' . escapeshellarg($file->queryModulePath()); $pipe = popen($cmd, 'r'); if (!is_resource($pipe)) { throw new Horde_Vcs_Exception('Unable to run ' . $cmd . ': ' . error_get_last()); @@ -288,8 +296,8 @@ class Horde_Vcs_Directory_Git extends Horde_Vcs_Directory public function browseDir($cache = null, $quicklog = true, $showattic = false) { - //@TODO For now, we're browsing HEAD - $head = trim(shell_exec($this->_rep->getCommand() . ' rev-parse --verify HEAD')); + //@TODO For now, we're browsing master + $head = trim(shell_exec($this->_rep->getCommand() . ' rev-parse --verify master')); //@TODO can use this to see if we have a valid cache of the tree at this revision $dir = $this->queryDir(); @@ -397,8 +405,7 @@ class Horde_Vcs_File_Git extends Horde_Vcs_File function getBrowseInfo() { // Get the list of revisions that touch this path - $Q = VC_WINDOWS ? '"' : "'"; - $cmd = $this->rep->getCommand() . ' rev-list HEAD -- ' . $Q . str_replace($Q, '\\' . $Q, $this->fullname) . $Q . ' 2>&1'; + $cmd = $this->rep->getCommand() . ' rev-list master -- ' . escapeshellarg($this->fullname) . ' 2>&1'; $revisions = shell_exec($cmd); if (substr($revisions, 5) == 'fatal') { throw new Horde_Vcs_Exception($revisions); @@ -409,12 +416,25 @@ class Horde_Vcs_File_Git extends Horde_Vcs_File } $this->revs = explode("\n", trim($revisions)); + foreach ($this->revs as $rev) { $this->logs[$rev] = Horde_Vcs_Log_Git::factory($this->rep, $this, $rev); if ($this->quicklog) { break; } } + + // Add branch information + $cmd = $this->rep->getCommand() . ' branch -l'; + $branch_list = shell_exec($cmd); + if (empty($branch_list)) { + throw new Horde_Vcs_Exception('No branches found'); + } + + $i = 0; + foreach (explode("\n", trim($branch_list)) as $val) { + $this->branches[++$i] = ltrim($val, '* '); + } } /**