*/
public function getCommand()
{
- return escapeshellcmd($this->getPath('git')) . ' --git-dir=' . escapeshellarg($this->_sourceroot);
+ return escapeshellcmd($this->getPath('git')) . ' --git-dir=' . escapeshellarg($this->sourceroot());
}
/**
* TODO
+ *
+ * @throws Horde_Vcs_Exception
*/
public function annotate($fileob, $rev)
{
}
pclose($pipe);
+
return $lines;
}
* @param string $rev Revision number to check out
*
* @return resource A stream pointer to the head of the checkout.
+ * @throws Horde_Vcs_Exception
*/
public function checkout($file, $rev)
{
* 'ws' - (boolean) DEFAULT: true
* </pre>
*
- * @return string|boolean False on failure, or a string containing the
- * diff on success.
+ * @return string The diff text.
*/
protected function _diff($file, $rev1, $rev2, $opts)
{
switch ($opts['type']) {
case 'unified':
- $flags .= '--unified=' . (int)$opts['num'];
+ $flags .= '--unified=' . escapeshellarg((int)$opts['num']);
break;
}
// @TODO: add options for $hr options - however these may not
// be compatible with some diffs.
- $command = $this->getCommand() . " diff -M -C $flags --no-color " . escapeshellarg($rev1 . '..' . $rev2) . ' -- ' . escapeshellarg($file->queryModulePath()) . ' 2>&1';
+ $command = $this->getCommand() . ' diff -M -C ' . $flags . ' --no-color ' . escapeshellarg($rev1 . '..' . $rev2) . ' -- ' . escapeshellarg($file->queryModulePath()) . ' 2>&1';
exec($command, $diff, $retval);
+
return $diff;
}
* @param Horde_Vcs $rep The Repository object this directory is part of.
* @param string $dn Path to the directory.
* @param array $opts TODO
+ *
+ * @throws Horde_Vcs_Exception
*/
public function __construct($rep, $dn, $opts = array())
{
parent::__construct($rep, $dn, $opts);
- // @TODO For now, we're browsing HEAD
- //$head = trim(shell_exec($this->_rep->getCommand() . ' rev-parse --verify master'));
- $head = 'HEAD';
+ // @TODO For now, we're browsing master
+ $branch = 'master';
+
// @TODO can use this to see if we have a valid cache of the tree at this revision
$dir = $this->queryDir();
$dir .= '/';
}
- $cmd = $rep->getCommand() . ' ls-tree --full-name ' . escapeshellarg($head) . ' ' . escapeshellarg($dir) . ' 2>&1';
+ $cmd = $rep->getCommand() . ' ls-tree --full-name ' . escapeshellarg($branch) . ' ' . escapeshellarg($dir) . ' 2>&1';
$dir = popen($cmd, 'r');
if (!$dir) {
* @param TODO $rep TODO
* @param string $fl Full path to this file.
* @param array $opts TODO
+ *
+ * @throws Horde_Vcs_Exception
*/
public function __construct($rep, $fl, $opts = array())
{
/**
* Constructor.
+ *
+ * @throws Horde_Vcs_Exception
*/
public function __construct($rep, $fl, $rev)
{
$line = fgets($pipe);
}
$this->_log = trim($log);
- // @TODO internal line formatting
// Build list of files in this revision. The format of these lines is
// documented in the git diff-tree documentation:
*/
public function getHashForPath($path)
{
- // @TODO Not confident yet abotu the choice of dstSha1 vs. srcSha1
return $this->_files[$path]['dstSha1'];
}
/**
- * Given a branch revision number, this function remaps it
- * accordingly, and performs a lookup on the file object to
- * return the symbolic name(s) of that branch in the tree.
- *
- * @return Hash of symbolic names => branch numbers
- */
- public function querySymbolicBranches()
- {
- return array();
- }
-
- /**
* TODO
*/
public function queryBranch()
case 'D':
$from = $to;
- $to = null;
$to = self::DEAD;
break;