some changes ...
[phpgitweb.git] / htdocs / lib / PageClasses.diff.class.php
index f02fb4607dcd2314be163ddddd97bae5a5628261..ca0bcd78f2f541de321f6b9d26ea0ee5316d1719 100644 (file)
@@ -90,26 +90,26 @@ class diff {
                $header = array();
                if(!$this->diff) {
                        $header[] = "diff --cc ";
-                       $header[] = new ContentProvider('commitdiff', 'patch_link_blob', array('hash' => $this->commit['id'], 'file' => $this->tree['to_file'], 'path' => ''));
+                       $header[] = new ContentProvider('commitdiff', 'patch_link_blob', array('hash' => $this->commit['id'], 'file' => $this->tree['to_file'], 'file_hash' => $this->tree['to_id'], 'path' => ''));
                } else if($this->tree['parents'] > 1) {
                        preg_match('!^(diff (.*?) )"?.*$!', $this->diff[0], $match);
                        $header[] = $match[1];
                        if(preg_match('/^[0]{40}$/', $this->tree['to_id']))
                                $header[] = $this->tree['to_file'];
                        else
-                               $header[] = new ContentProvider('commitdiff', 'patch_link_blob', array('hash' => $this->commit['id'], 'file' => $this->tree['to_file'], 'path' => ''));
+                               $header[] = new ContentProvider('commitdiff', 'patch_link_blob', array('hash' => $this->commit['id'], 'file' => $this->tree['to_file'], 'file_hash' => $this->tree['to_id'], 'path' => ''));
                } else {
                        preg_match('!^(diff (.*?) )"?a/.*$!', $this->diff[0], $match);
                        $header[] = $match[1];
                        if(preg_match('/^[0]{40}$/', $this->tree['from_id']))
                                $header[] = 'a/'.$this->tree['file'];
                        else
-                               $header[] = new ContentProvider('commitdiff', 'patch_link_blob', array('hash' => $this->commit['parent'][0], 'file' => $this->tree['from_file'], 'path' => 'a/'));
+                               $header[] = new ContentProvider('commitdiff', 'patch_link_blob', array('hash' => $this->commit['parent'][0], 'file' => $this->tree['from_file'], 'file_hash' => $this->tree['from_id'], 'path' => 'a/'));
                        $header[] = ' ';
                        if(preg_match('/^[0]{40}$/', $this->tree['to_id']))
                                $header[] = 'b/'.$this->tree['file'];
                        else
-                               $header[] = new ContentProvider('commitdiff', 'patch_link_blob', array('hash' => $this->commit['id'], 'file' => $this->tree['to_file'], 'path' => 'b/'));
+                               $header[] = new ContentProvider('commitdiff', 'patch_link_blob', array('hash' => $this->commit['id'], 'file' => $this->tree['to_file'], 'file_hash' => $this->tree['to_id'], 'path' => 'b/'));
                }
                return $header;
        }
@@ -122,10 +122,14 @@ class diff {
                                $this->data['copy']++;
                        else
                                $this->data['copy'] = 0;
-                       $header[] = new ContentProvider('commitdiff', 'patch_link_blob', array('hash' => $this->commit['parent'][$this->data['copy']], 'file' => $this->tree['from_file'], 'path' => ''));
+                       if(is_array($this->tree['from_id']))
+                               $from_id = $this->tree['from_id'][$this->data['copy']];
+                       else
+                               $from_id = $this->tree['from_id'];
+                       $header[] = new ContentProvider('commitdiff', 'patch_link_blob', array('hash' => $this->commit['parent'][$this->data['copy']], 'file' => $this->tree['from_file'], 'file_hash' => $from_id, 'path' => ''));
                } else if(preg_match('/^((copy|rename) to ).*$/', $line, $matches)) {
                        $header[] = $matches[1];
-                       $header[] = new ContentProvider('commitdiff', 'patch_link_blob', array('hash' => $this->commit['id'], 'file' => $this->tree['to_file'], 'path' => ''));
+                       $header[] = new ContentProvider('commitdiff', 'patch_link_blob', array('hash' => $this->commit['id'], 'file' => $this->tree['to_file'], 'file_hash' => $this->tree['to_id'], 'path' => ''));
                } else if(preg_match('/^(index )[0-9a-fA-F]{40},[0-9a-fA-F]{40}/', $line, $matches)) { //combined diff
                        $header[] = $matches[1];
                        $parent_id = 0;
@@ -135,7 +139,7 @@ class diff {
                                if(preg_match('/^[0]{40}$/', $from_id))
                                        $header[] = '0000000';
                                else
-                                       $header[] = new ContentProvider('commitdiff', 'patch_link_blob_id', array('hash' => $this->commit['parent'][$parent_id], 'file' => $this->tree['from_file'], 'id' => substr($from_id, 0, 7)));
+                                       $header[] = new ContentProvider('commitdiff', 'patch_link_blob_id', array('hash' => $this->commit['parent'][$parent_id], 'file' => $this->tree['from_file'], 'file_hash' => $from_id, 'id' => substr($from_id, 0, 7)));
                                $parent_id++;
                        }
                } else if(preg_match('/^(index )([0-9a-fA-F]{40})..([0-9a-fA-F]{40})/', $line, $matches)) {
@@ -143,12 +147,12 @@ class diff {
                        if(preg_match('/^[0]{40}$/', $matches[2]))
                                $header[] = '0000000';
                        else
-                               $header[] = new ContentProvider('commitdiff', 'patch_link_blob_id', array('hash' => $this->commit['parent'][0], 'file' => $this->tree['from_file'], 'id' => substr($matches[2], 0, 7)));
+                               $header[] = new ContentProvider('commitdiff', 'patch_link_blob_id', array('hash' => $this->commit['parent'][0], 'file' => $this->tree['from_file'], 'file_hash' => $this->tree['from_id'], 'id' => substr($matches[2], 0, 7)));
                        $header[] = '..';
                        if(preg_match('/^[0]{40}$/', $matches[3]))
                                $header[] = '0000000';
                        else
-                               $header[] = new ContentProvider('commitdiff', 'patch_link_blob_id', array('hash' => $this->commit['id'], 'file' => $this->tree['to_file'], 'id' => substr($matches[3], 0, 7)));
+                               $header[] = new ContentProvider('commitdiff', 'patch_link_blob_id', array('hash' => $this->commit['id'], 'file' => $this->tree['to_file'], 'file_hash' => $this->tree['to_id'], 'id' => substr($matches[3], 0, 7)));
                } else
                        $header[] = $line;
                if(preg_match('/([0-7]{6})$/', $line, $matches)) {