More work on tags/branches.
authorMichael M Slusarz <slusarz@curecanti.org>
Thu, 22 Jan 2009 14:02:59 +0000 (07:02 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 22 Jan 2009 14:18:29 +0000 (07:18 -0700)
Tearing apart code to get it to work properly. Display of branches with
both CVS and Git looks good - however, the code has been removed to view
only commits on a certain branch (since it was CVS specific). This code
will be rewritten in the individual drivers.

Change supportsFeature() -> hasFeature()

Distinguish between heads (branches) and tags in Git.

16 files changed:
chora/browse.php
chora/co.php
chora/cvsgraph.php
chora/diff.php
chora/history.php
chora/lib/Chora.php
chora/lib/base.php
chora/patchsets.php
chora/templates/checkout/checkout.inc
chora/templates/diff/hr/header.inc
chora/templates/headerbar.inc
chora/templates/log/rev.inc
framework/Vcs/lib/Horde/Vcs.php
framework/Vcs/lib/Horde/Vcs/Cvs.php
framework/Vcs/lib/Horde/Vcs/Git.php
framework/Vcs/lib/Horde/Vcs/Svn.php

index 024a414..ce7b9ed 100644 (file)
@@ -32,7 +32,7 @@ if ($atdir) {
         ? $conf['options']['introTitle']
         : sprintf(_("Source Directory of /%s"), $where);
 
-    $extraLink = $VC->supportsFeature('deleted')
+    $extraLink = $VC->hasFeature('deleted')
         ? Horde::widget(Chora::url('', $where . '/', array('sa' => ($acts['sa'] ? 0 : 1))), $acts['sa'] ? _("Hide Deleted Files") : _("Show Deleted Files"), 'widget', '', '', $acts['sa'] ? _("Hide _Deleted Files") : _("Show _Deleted Files"))
         : '';
 
@@ -125,22 +125,15 @@ if ($atdir) {
 }
 
 /* Showing a file. */
-$fl = $VC->getFileObject($where, $cache);
-Chora::checkError($fl);
-$title = sprintf(_("Revisions for %s"), $where);
+// TODO - onb is j
 $onb = Util::getFormData('onb', 0);
 if ($VC->isValidRevision($onb)) {
-    $onb_len = strlen($onb);
-    $onb_base = $rev_ob->strip($onb, 1);
-    $onb_parents = array();
-    while (substr_count($onb_base, '.')) {
-        $onb_parents[$onb_base] = true;
-        $onb_base = $rev_ob->strip($onb_base, 1);
-    }
-} else {
-    $onb = null;
 }
 
+$fl = $VC->getFileObject($where, $cache);
+Chora::checkError($fl);
+$title = sprintf(_("Revisions for %s"), $where);
+
 $extraLink = Chora::getFileViews();
 $first = end($fl->logs);
 $diffValueLeft = $first->queryRevision();
@@ -152,8 +145,10 @@ foreach ($fl->symrev as $sm => $rv) {
 }
 
 $selAllBranches = '';
-foreach ($fl->branches as $num => $sym) {
-    $selAllBranches .= '<option value="' . $num . '"' . ($num == $onb ? ' selected="selected"' : '') . '>' . $sym . '</option>';
+if ($VC->hasFeature('branches')) {
+    foreach (array_keys($fl->branches) as $sym) {
+        $selAllBranches .= '<option value="' . $sym . '">' . $sym . '</option>';
+    }
 }
 
 Horde::addScriptFile('prototype.js', 'horde', true);
@@ -168,20 +163,7 @@ require CHORA_TEMPLATES . '/log/header.inc';
 $i = 0;
 foreach ($fl->logs as $lg) {
     $rev = $lg->queryRevision();
-    list($branchName, $branchRev) = Chora::getBranch($fl, $rev);
-
-    /* Are we tracking a branch? */
-    if ($onb) {
-        /* If we are on the branch itself, let it through */
-        if (substr($rev, 0, $onb_len) != $onb) {
-            /* If the revision is on one of the parent branches, and
-             * is before the branch was made, let it through. */
-            if ((!isset($onb_parents[$branchRev]) && substr_count($rev, '.') > 1) ||
-                $rev_ob->cmp($rev, $onb) > 0) {
-                continue;
-            }
-        }
-    }
+    $branch_info = Chora::getBranch($fl, $rev);
 
     $textUrl = Chora::url('co', $where, array('r' => $rev));
     $commitDate = Chora::formatDate($lg->queryDate());
@@ -200,7 +182,7 @@ foreach ($fl->logs as $lg) {
 
     require CHORA_TEMPLATES . '/log/rev.inc';
 
-    if ($i++ > 100 && !Util::getFormData('all')) {
+    if (($i++ > 100) && !Util::getFormData('all')) {
         break;
     }
 }
index 8019b7f..ecfe0ec 100644 (file)
@@ -70,7 +70,7 @@ if (!$plain) {
                          Chora::url('co', $where, array('r' => $r, 'p' => 1)), _("Download"));
 
     $tags = Chora::getTags($log, $where);
-    list($branchName,) = Chora::getBranch($file, $r);
+    $branch_info = Chora::getBranch($file, $r);
 
     $log_print = Chora::formatLogMessage($log->queryLog());
     $author = Chora::showAuthorName($log->queryAuthor(), true);
index 2d6749c..85fe68d 100644 (file)
@@ -15,7 +15,7 @@
 require_once dirname(__FILE__) . '/lib/base.php';
 
 // Exit if cvsgraph isn't active or it's not supported.
-if (empty($conf['paths']['cvsgraph']) || !$VC->supportsFeature('branches')) {
+if (empty($conf['paths']['cvsgraph']) || !$VC->hasFeature('branches')) {
     header('Location: ' . Chora::url('', $where));
     exit;
 }
index fe5fba8..614890c 100644 (file)
@@ -59,14 +59,12 @@ $log = &$fl->logs;
 $log_messages = array();
 foreach ($VC->getRevisionRange($fl, $r1, $r2) as $val) {
     if (isset($log[$val])) {
-        list($branchname, $branchrev) = Chora::getBranch($fl, $val);
         $clog = $log[$val];
         $log_messages[] = array(
             'rev' => $val,
             'msg' => Chora::formatLogMessage($clog->queryLog()),
             'author' => Chora::showAuthorName($clog->queryAuthor(), true),
-            'branchRev' => $branchrev,
-            'branchName' => $branchname,
+            'branchinfo' => Chora::getBranch($fl, $val),
             'date' => Chora::formatDate($clog->queryDate()),
             'tags' => Chora::getTags($clog, $where),
         );
index bb2b2ae..d1d4a04 100644 (file)
 require_once dirname(__FILE__) . '/lib/base.php';
 
 /* Exit if it's not supported. */
-if (!$VC->supportsFeature('branches')) {
+if (!$VC->hasFeature('branches')) {
     header('Location: ' . Chora::url('browse', $where));
     exit;
 }
 
 /* Spawn the file object. */
 $fl = $VC->getFileObject($where, $cache);
-$rev_ob = $VC->getRevisionObject();
 Chora::checkError($fl);
+$rev_ob = $VC->getRevisionObject();
 
 /* $trunk contains an array of trunk revisions. */
 $trunk = array();
@@ -30,7 +30,7 @@ $trunk = array();
 $branches = array();
 
 /* Populate $col with a list of all the branch points. */
-foreach ($fl->branches as $rev => $sym) {
+foreach ($fl->branches as $rev) {
     $branches[$rev] = array();
 }
 
index 3a3356e..0b40229 100644 (file)
@@ -506,14 +506,14 @@ class Chora
                             '', _("_Logs"));
 
         if (!empty($GLOBALS['conf']['paths']['cvsps']) ||
-            $GLOBALS['VC']->supportsFeature('patchsets')) {
+            $GLOBALS['VC']->hasFeature('patchsets')) {
             $views[] = $current == 'patchsets'
                 ? '<em class="widget">' . _("Patchsets") . '</em>'
                 : Horde::widget(Chora::url('patchsets', $where), _("Patchsets"),
                                 'widget', '', '', _("_Patchsets"));
         }
 
-        if ($GLOBALS['VC']->supportsFeature('branches')) {
+        if ($GLOBALS['VC']->hasFeature('branches')) {
             if (empty($GLOBALS['conf']['paths']['cvsgraph'])) {
                 $views[] = $current == 'history'
                     ? '<em class="widget">' . _("Branches") . '</em>'
@@ -583,13 +583,17 @@ class Chora
      * Return branch information for a given revision.
      *
      * @param Horde_Vcs_File $fl  The Horde_Vcs_File object.
-     * @param string $rev         The filename.
+     * @param string $rev         The revision string.
      *
-     * @return array  A 2-member array - branch name and branch revision.
+     * @return array  TODO
      */
     static public function getBranch($fl, $rev)
     {
-        $branchName = '';
+        return $GLOBALS['VC']->hasFeature('branches')
+            ? array_keys($fl->branches, $rev)
+            : array();
+
+        /*
         $rev_ob = $fl->rep->getRevisionObject();
         $branchRev = $rev_ob->strip($rev, 1);
         if (isset($fl->branches[$rev])) {
@@ -598,6 +602,7 @@ class Chora
             $branchName = $fl->branches[$branchRev];
         }
         return array($branchName, $branchRev);
+        */
     }
 
     /**
index f055d07..8689263 100644 (file)
@@ -45,7 +45,9 @@ $notification = &Notification::singleton();
 $notification->attach('status');
 
 // Cache.
-if (!empty($conf['caching'])) {
+if (empty($conf['caching'])) {
+    $cache = null;
+} else {
     $cache = &Horde_Cache::singleton($conf['cache']['driver'], Horde::getDriverConfig('cache', $conf['cache']['driver']));
 }
 
index c7e99b4..cb79480 100644 (file)
@@ -14,7 +14,7 @@ require_once dirname(__FILE__) . '/lib/base.php';
 
 // Exit if cvsps isn't active or it's not a subversion repository.
 if (empty($conf['paths']['cvsps']) &&
-    !$GLOBALS['VC']->supportsFeature('patchsets')) {
+    !$GLOBALS['VC']->hasFeature('patchsets')) {
     header('Location: ' . Chora::url('', $where));
     exit;
 }
@@ -43,7 +43,7 @@ foreach ($patchsets as $id => $patchset) {
     $commitDate = Chora::formatDate($patchset['date']);
     $readableDate = Chora::readableTime($patchset['date'], true);
     $author = Chora::showAuthorName($patchset['author'], true);
-    if ($VC->supportsFeature('patchsets')) {
+    if ($VC->hasFeature('patchsets')) {
         // The diff should be from the top of the source tree so as to
         // get all files.
         $topDir = substr($where, 0, strpos($where, '/', 1));
@@ -60,7 +60,7 @@ foreach ($patchsets as $id => $patchset) {
     $dir = dirname($where);
     foreach ($patchset['members'] as $member) {
         $file = array();
-        $mywhere = ($VC->supportsFeature('patchsets')) ? $member['file'] : $dir . '/' . $member['file'];
+        $mywhere = ($VC->hasFeature('patchsets')) ? $member['file'] : $dir . '/' . $member['file'];
         $file['file'] = Horde::link(Chora::url('patchsets', $mywhere)) . htmlspecialchars($member['file']) . '</a>';
         if ($member['from'] == 'INITIAL') {
             $file['from'] = '<ins>' . _("New File") . '</ins>';
index 03eb745..96091ba 100644 (file)
@@ -2,7 +2,13 @@
 <div class="revision_log">
  <ul class="revision striped">
   <?php if ($author): ?><li><?php echo _("Author:") ?> <?php echo $author ?></li><?php endif; ?>
-  <?php if ($branchName): ?><li><?php echo _("Branch:") ?> <strong><a href="<?php echo Chora::url('', $where, array('onb' => $branchRev)) ?>"><?php echo $branchName ?></a></strong></li><?php endif; ?>
+<?php if (!empty($branch_info)): ?>
+  <li><?php echo _("Branch:") ?>
+<?php foreach ($branch_info as $val): ?>
+   <strong><a href="<?php echo Chora::url('', $where, array('onb' => $val)) ?>"><?php echo $val ?></a></strong>
+<?php endforeach; ?>
+  </li>
+<?php endif; ?>
   <?php if ($tags): ?><li class="tags"><?php echo _("Tags:") ?> <?php echo implode(', ', $tags) ?></li><?php endif; ?>
  </ul>
  <?php echo $log_print ?>
index 6360fc2..365c404 100644 (file)
   <ul class="revision striped">
    <?php if (!empty($val['author'])): ?><li><?php echo _("Author:") ?> <?php echo $val['author'] ?></li><?php endif; ?>
    <?php if (!empty($val['date'])): ?><li><?php echo _("Date:") ?> <?php echo $val['date'] ?></li><?php endif; ?>
-   <?php if (!empty($val['branchName'])): ?><li><?php echo _("Branch:") ?> <strong><a href="<?php echo Chora::url('', $where, array('onb' => $val['branchRev'])) ?>"><?php echo $val['branchName'] ?></a></strong></li><?php endif; ?>
+<?php if (!empty($val['branchinfo'])): ?>
+   <li><?php echo _("Branch:") ?>
+<?php foreach ($val['branchinfo'] as $branchname): ?>
+    <strong><a href="<?php echo Chora::url('', $where, array('onb' => $branchname)) ?>"><?php echo $branchname ?></a></strong>
+<?php endforeach; ?>
+   </li>
+<?php endif; ?>
    <?php if (!empty($val['tags'])): ?><li class="tags"><?php echo _("Tags:") ?> <?php echo implode(', ', $val['tags']) ?></li><?php endif; ?>
   </ul>
   <a href="<?php echo Chora::url('co', $where, array('r' => $val['rev'])) ?>" title="<?php echo htmlspecialchars($val['rev']) ?>"><?php echo htmlspecialchars($rev_ob->abbrev($val['rev'])) ?></a>: <?php echo $val['msg'] ?>
index 01819ba..2110d88 100644 (file)
@@ -5,8 +5,8 @@
    <?php echo _("Location:") ?>
    <strong>[ <a href="<?php echo Chora::url('') ?>"><?php echo $conf['options']['sourceRootName'] ?></a> ]
    <?php echo Chora::whereMenu() ?></strong>
-   <?php if (isset($fl) && isset($onb) && isset($fl->branches[$onb])): ?>
-    <em>(<?php echo _("Tracking Branch") ?> <strong><?php echo $fl->branches[$onb] ?></strong>)</em>
+   <?php if (!empty($onb)): ?>
+    <em>(<?php echo _("Tracking Branch") ?> <strong><?php echo $onb ?></strong>)</em>
    <?php endif; ?>
   </td>
 <?php if (!empty($extraLink)): ?>
index bbab6e0..6bf793e 100644 (file)
@@ -5,13 +5,20 @@
   <?php endif ?>
   <a href="<?php echo Chora::url('diff', $where, array('r1' => 0, 'r2' => $rev)) ?>" class="sdiff" title="<?php echo _("Show changes to the selected revision") ?>" onclick="Chora_RevLog.sdiff(this);"><?php echo Horde::img('diff.png') ?></a>
  </td>
- <td><a href="<?php echo $textUrl ?>" title="<?php echo htmlspecialchars($rev) ?>"><?php echo htmlspecialchars($rev_ob->abbrev($rev)) . '</a>'; if ($branchName) echo ' <span class="branch">' . Horde::link(Chora::url('', $where, array('onb' => $branchRev))) . htmlspecialchars($branchName) . '</a></span>'; if (!empty($lg->lines)) echo ' <small>(' . sprintf('%s lines', $lg->lines) . ')</small>'; ?></td>
+ <td><a href="<?php echo $textUrl ?>" title="<?php echo htmlspecialchars($rev) ?>"><?php echo htmlspecialchars($rev_ob->abbrev($rev)) ?></a>
+<?php foreach (array_diff($branch_info, array($onb)) as $val): ?>
+  <span class="branch"><?php echo Horde::link(Chora::url('', $where, array('onb' => $val))) . htmlspecialchars($val) ?></a></span>
+<?php endforeach; ?>
+<?php if (!empty($lg->lines)): ?>
+  <small>(<?php printf('%s lines', $lg->lines) ?>)</small>
+<?php endif; ?>
+</td>
  <td class="ago" sortval="<?php echo (int)$lg->date ?>"><a title="<?php echo $readableDate ?>"><?php echo $commitDate ?></a></td>
  <td class="author"><?php echo $author ?></td>
  <td class="log">
-<?php
-echo '<p class="message">' . $logMessage . '</p>';
-if ($tags) echo '<p class="tags">' . _("Tags") . ': ' . implode(', ', $tags) . '</p>';
-?>
+  <p class="message"><?php echo $logMessage ?></p>
+<?php if ($tags): ?>
+  <p class="tags"><?php echo _("Tags") . ': ' . implode(', ', $tags) ?></p>
+<?php endif; ?>
  </td>
 </tr>
index 360910a..535a364 100644 (file)
@@ -112,11 +112,11 @@ class Horde_Vcs
     }
 
     /**
-     * Does this driver support the given feature
+     * Does this driver support the given feature?
      *
      * @return boolean  True if driver supports the given feature.
      */
-    public function supportsFeature($feature)
+    public function hasFeature($feature)
     {
         switch ($feature) {
         case 'branches':
@@ -741,13 +741,13 @@ class Horde_Vcs_File
     public $rep;
     public $dir;
     public $name;
-    public $logs;
-    public $revs;
+    public $logs = array();
+    public $revs = array();
     public $head;
     public $quicklog;
-    public $symrev;
-    public $revsym;
-    public $branches;
+    public $symrev = array();
+    public $revsym = array();
+    public $branches = array();
     public $revob;
 
     /**
@@ -919,10 +919,10 @@ class Horde_Vcs_Log
     /**
      * Constructor.
      */
-    public function __construct($rep, $fl)
+    public function __construct($fl)
     {
-        $this->rep = $rep;
         $this->file = $fl;
+        $this->rep = $fl->rep;
     }
 
     public function queryDate()
@@ -955,20 +955,16 @@ class Horde_Vcs_Log
      * 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
+     * @return array  Hash of symbolic names => branch numbers.
      */
     public function querySymbolicBranches()
     {
         $symBranches = array();
 
         foreach ($this->branches as $branch) {
-            $parts = explode('.', $branch);
-            $last = array_pop($parts);
-            $parts[] = '0';
-            $parts[] = $last;
-            $rev = implode('.', $parts);
-            if (isset($this->file->branches[$branch])) {
-                $symBranches[$this->file->branches[$branch]] = $branch;
+            $key = array_search($branch, $this->file->branches);
+            if ($key !== false) {
+                $symBranches[$key] = $branch;
             }
         }
 
index 9f020ab..b24efa2 100644 (file)
@@ -453,7 +453,6 @@ class Horde_Vcs_File_Cvs extends Horde_Vcs_File
         $this->filename = $fl;
         $this->cache = $cache;
         $this->quicklog = $quicklog;
-        $this->logs = $this->revs = $this->branches = array();
     }
 
     public function &getFileObject()
@@ -563,7 +562,7 @@ class Horde_Vcs_File_Cvs extends Horde_Vcs_File
             case 'init':
                 if (!strncmp('head: ', $line, 6)) {
                     $this->head = substr($line, 6);
-                    $this->branches[$this->head] = 'HEAD';
+                    $this->branches['HEAD'] = $this->head;
                 } elseif (!strncmp('branch:', $line, 7)) {
                     $state = 'rev';
                 }
@@ -578,9 +577,7 @@ class Horde_Vcs_File_Cvs extends Horde_Vcs_File
                     // Check to see if this is a branch
                     if (preg_match('/^(\d+(\.\d+)+)\.0\.(\d+)$/', $regs[2])) {
                         $branchRev = $this->toBranch($regs[2]);
-                        if (!isset($this->branches[$branchRev])) {
-                            $this->branches[$branchRev] = $regs[1];
-                        }
+                        $this->branches[$regs[1]] = $branchRev;
                     } else {
                         $symrev[$regs[1]] = $regs[2];
                         if (empty($revsym[$regs[2]])) {
@@ -598,7 +595,7 @@ class Horde_Vcs_File_Cvs extends Horde_Vcs_File
                 } elseif (count($accum)) {
                     // Spawn a new Horde_Vcs_Log object and add it to the logs
                     // hash.
-                    $log = new Horde_Vcs_Log_Cvs($this->rep, $this->filename);
+                    $log = new Horde_Vcs_Log_Cvs($this);
                     $err = $log->processLog($accum);
                     // TODO: error checks - avsm
                     $this->logs[$log->queryRevision()] = $log;
@@ -702,12 +699,14 @@ class Horde_Vcs_Log_Cvs extends Horde_Vcs_Log
             case 'branches':
                 /* If we find a branch tag, process and pop it,
                    otherwise leave input stream untouched */
-                if (!empty($raw) && preg_match("/^branches:\s+(.*)/", $raw[0], $br)) {
+                if (!empty($raw) &&
+                    preg_match("/^branches:\s+(.*)/", $raw[0], $br)) {
                     /* Get the list of branches from the string, and
                      * push valid revisions into the branches array */
                     $brs = preg_split('/;\s*/', $br[1]);
                     foreach ($brs as $brpoint) {
                         if ($this->rep->isValidRevision($brpoint)) {
+                            // TODO: Need branchname
                             $this->branches[] = $brpoint;
                         }
                     }
index 35ce9ba..96d5f1a 100644 (file)
@@ -25,8 +25,7 @@ class Horde_Vcs_Git extends Horde_Vcs
      *
      * @var boolean
      */
-    /* @TODO */
-    protected $_branches = false;
+    protected $_branches = true;
 
     /**
      * Constructor.
@@ -88,7 +87,7 @@ class Horde_Vcs_Annotate_Git extends Horde_Vcs_Annotate
         $command = $this->_rep->getCommand() . ' blame -p ' . $rev . ' -- ' . escapeshellarg($this->_file->queryModulePath()) . ' 2>&1';
         $pipe = popen($command, 'r');
         if (!$pipe) {
-            return PEAR::raiseError('Failed to execute git annotate: ' . $command);
+            throw new Horde_Vcs_Exception('Failed to execute git annotate: ' . $command);
         }
 
         $curr_rev = null;
@@ -163,9 +162,11 @@ class Horde_Vcs_Checkout_Git extends Horde_Vcs_Checkout
 
         $file_ob = $rep->getFileObject($file);
 
-        return ($pipe = popen($rep->getCommand() . ' cat-file blob ' . $file_ob->getHashForRevision($rev) . ' 2>&1', VC_WINDOWS ? 'rb' : 'r'))
-            ? $pipe
-            : PEAR::raiseError('Couldn\'t perform checkout of the requested file');
+        if ($pipe = popen($rep->getCommand() . ' cat-file blob ' . $file_ob->getHashForRevision($rev) . ' 2>&1', VC_WINDOWS ? 'rb' : 'r')) {
+            return $pipe;
+        }
+
+        throw new Horde_Vcs_Exception('Couldn\'t perform checkout of the requested file');
     }
 
 }
@@ -312,7 +313,7 @@ class Horde_Vcs_Directory_Git extends Horde_Vcs_Directory
 
         $dir = popen($cmd, 'r');
         if (!$dir) {
-            return PEAR::raiseError('Failed to execute git ls-tree: ' . $cmd);
+            throw new Horde_Vcs_Exception('Failed to execute git ls-tree: ' . $cmd);
         }
 
         // Create two arrays - one of all the files, and the other of
@@ -366,10 +367,11 @@ class Horde_Vcs_File_Git extends Horde_Vcs_File
         $this->dir = dirname($fl);
         $this->quicklog = $quicklog;
         $this->cache = $cache;
-
-        $this->logs = $this->revs = $this->revsym = $this->symrev = $this->branches = array();
     }
 
+    /**
+     * TODO
+     */
     public function getFileObject()
     {
         $this->getBrowseInfo();
@@ -379,9 +381,9 @@ class Horde_Vcs_File_Git extends Horde_Vcs_File
     /**
      * Get the hash name for this file at a specific revision.
      *
-     * @param string $rev
+     * @param string $rev  TODO
      *
-     * @return string Commit hash
+     * @return string  Commit hash.
      */
     public function getHashForRevision($rev)
     {
@@ -392,7 +394,7 @@ class Horde_Vcs_File_Git extends Horde_Vcs_File
      * Returns name of the current file without the repository
      * extensions (usually ,v)
      *
-     * @return Filename without repository extension
+     * @return string  Filename without repository extension
      */
     function queryName()
     {
@@ -402,13 +404,12 @@ class Horde_Vcs_File_Git extends Horde_Vcs_File
     /**
      * Populate the object with information about the revisions logs
      * and dates of the file.
-     *
-     * @return mixed  True on success, PEAR_Error on error.
      */
     function getBrowseInfo()
     {
         // Get the list of revisions that touch this path
-        $cmd = $this->rep->getCommand() . ' rev-list ' . escapeshellarg($this->_branch) . ' -- ' . escapeshellarg($this->fullname) . ' 2>&1';
+        // TODO: Gets all revisions
+        $cmd = $this->rep->getCommand() . ' rev-list --branches -- ' . escapeshellarg($this->fullname) . ' 2>&1';
         $revisions = shell_exec($cmd);
         if (substr($revisions, 5) == 'fatal') {
             throw new Horde_Vcs_Exception($revisions);
@@ -421,22 +422,22 @@ 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);
+            $this->logs[$rev] = Horde_Vcs_Log_Git::factory($this, $rev);
             if ($this->quicklog) {
                 break;
             }
         }
 
         // Add branch information
-        $cmd = $this->rep->getCommand() . ' branch -l';
+        $cmd = $this->rep->getCommand() . ' show-ref --heads';
         $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, '* ');
+            $line = explode(' ', trim($val), 2);
+            $this->branches[substr($line[1], strrpos($line[1], '/') + 1)] = $line[0];
         }
     }
 
@@ -467,26 +468,26 @@ class Horde_Vcs_Log_Git extends Horde_Vcs_Log {
     public $err;
     public $files = array();
 
-    public static function factory($rep, $file, $rev)
+    public static function factory($file, $rev)
     {
         /* The version of the cached data. Increment this whenever the
          * internal storage format changes, such that we must
          * invalidate prior cached data. */
         $cacheVersion = 1;
-        $cacheId = $rep->sourceroot() . '_r' . $rev . '_v' . $cacheVersion;
+        $cacheId = $file->rep->sourceroot() . '_r' . $rev . '_v' . $cacheVersion;
 
         /* @TODO: No caching during dev */
         if (0 &&
-            $rep->cache &&
+            $file->rep->cache &&
             // Individual revisions can be cached forever
-            $rep->cache->exists($cacheId, 0)) {
-            $logOb = unserialize($rep->cache->get($cacheId, 0));
-            $logOb->setRepository($rep);
+            $file->rep->cache->exists($cacheId, 0)) {
+            $logOb = unserialize($file->rep->cache->get($cacheId, 0));
+            $logOb->setRepository($file->rep);
         } else {
-            $logOb = new Horde_Vcs_Log_Git($rep, $file, $rev);
+            $logOb = new Horde_Vcs_Log_Git($file, $rev);
 
-            if ($rep->cache) {
-                $rep->cache->set($cacheId, serialize($logOb));
+            if ($file->rep->cache) {
+                $file->rep->cache->set($cacheId, serialize($logOb));
             }
         }
 
@@ -496,9 +497,9 @@ class Horde_Vcs_Log_Git extends Horde_Vcs_Log {
     /**
      * Constructor.
      */
-    public function __construct($rep, $fl, $rev)
+    public function __construct($fl, $rev)
     {
-        parent::__construct($rep, $fl);
+        parent::__construct($fl);
 
         $this->rev = $rev;
 
@@ -534,8 +535,8 @@ class Horde_Vcs_Log_Git extends Horde_Vcs_Log {
                     $value = substr($value, 1, -1);
                     foreach (explode(',', $value) as $val) {
                         $val = trim($val);
-                        if (($pos = strrpos($val, '/')) !== false) {
-                            $this->tags[] = substr($val, $pos + 1);
+                        if (strpos($val, 'refs/tags/') === 0) {
+                            $this->tags[] = substr($val, 10);
                         }
                     }
                     if (!empty($this->tags)) {
index c6343b6..44ce098 100644 (file)
@@ -323,7 +323,6 @@ class Horde_Vcs_File_Svn extends Horde_Vcs_File {
         $this->filename = $fl;
         $this->quicklog = $quicklog;
         $this->cache = $cache;
-        $this->logs = $this->revs = $this->revsym = $this->symrev = $this->branches = array();
     }
 
     public function getFileObject()