added hash_base system (base refs gets stored in the _SESSION)
[phpgitweb.git] / htdocs / pages / commit.class.php
index 3c10b4486d1798bb7675eaac08b9de1863202158..57f20e5d8b18def5b68871a9bd58e9595cc67956 100644 (file)
  * along with this program. If not, see <http://www.gnu.org/licenses/>. 
  */
 
-require_once('pages/shortlog.class.php');
-
 class difftree {
+       private $difftree_data = null;
+       
+       public function push_difftree_data($data) {
+               $this->difftree_data = $data;
+       }
        
        public function generate_difftree($project, $commit, $patch_link) {
                $difftree = new ContentProvider('commit', 'difftree');
-               $tree = GitCommand::get_commit_changes($project['path'], $commit['id'], $commit['parent']);
+               if($this->difftree_data)
+                       $tree = $this->difftree_data;
+               else
+                       $tree = GitCommand::get_commit_changes($project['path'], $commit['id'], $commit['parent']);
                $entry_count = 0;
                if(count($commit['parent']) > 1)
                        $difftree->set('class', ' combined');
                else
                        $difftree->set('class', '');
+               $difftree->set('tree_count', '');
                foreach($tree as $entry) {
                        $entry_count++;
                        $difftree->append('tree', $this->tree_entry($entry_count, (($entry_count % 2) ? 'dark' : 'light'), $commit, $entry, $patch_link));
                }
-               if(count($tree) == 0)
+               if($entry_count == 0)
                        $difftree->set('tree', '');
+               else if($entry_count > 10)
+                       $difftree->set('tree_count', new ContentProvider('commit', 'tree_count', array('count' => $entry_count)));
                return $difftree;
        }
        
@@ -138,7 +147,7 @@ class difftree {
                                        }
                                } else
                                        $tree->set('specials', '');
-                               if($entry['from_id'] != $entry['to_id'])
+                               if(!$patch_link && $entry['from_id'] != $entry['to_id'])
                                        $tree->append('links', new ContentProvider('commit', 'tree_changed_links_diff', $link_placeholders));
                                $tree->append('links', new ContentProvider('commit', 'tree_changed_links', $link_placeholders));
                                break;
@@ -171,7 +180,6 @@ class difftree {
 
 class page_commit {
     private $page, $phpgitweb;
-       private $commitid;
        
     public function main($phpgitweb, $project) {
                $this->phpgitweb = $phpgitweb;
@@ -180,19 +188,14 @@ class page_commit {
                $project['refs'] = $phpgitweb->get_project_loader()->getProjectRefs($project);
                $phpgitweb->append_header_nav("commit", null, true);
                $phpgitweb->append_title("commit");
+               CommitLoader::parse();
                
                $commit_loader = new CommitLoader($project);
-               
-               if(array_key_exists('h', $_GET))
-                       $commitid = $_GET['h'];
-               else
-                       $commitid = "HEAD";
-               
-               $commit = $commit_loader->load($commitid);
+               $commit = $commit_loader->load();
                if(!$commit)
                        return new ContentProvider('main', 'err404_object');
                
-               ContentProvider::overall_set('project_head', $commit['id']);
+               ContentProvider::overall_set('commit_id', $commit['id']);
                
                
                $this->page = new ContentProvider('commit', 'main');
@@ -215,7 +218,7 @@ class page_commit {
                else
                        $this->page->set('committer_local_date', gmdate('H:i', $committer_local_time));
                $this->page->set('committer_timezone', $commit['committer_timezone']);
-               $this->page->set('message', htmlentities(Tools::chop_text($commit['text'], 50, 5)));
+               $this->page->set('message', htmlentities(Tools::chop_text($commit['text'], 80, 5)));
                $this->page->set('full_message', htmlentities($commit['text']));
                $this->page->set('tree_hash', $commit['tree']);
                foreach($commit['parent'] as $parent) {