fixed small graph error
[phpgitweb.git] / htdocs / lib / graph.class.php
index 53f1aaee6fa5ca5120a6f492037d28ceca9cf3d5..78deef381d341161ca9e988b45e654af1fcf8fb1 100644 (file)
@@ -42,13 +42,16 @@ class graph_data_generator {
                }
                unset($branch);
                if($existing)
-                       continue;
+                       return;
+               $name_arr = array();
+               if($name)
+                       $name_arr[] = $name;
                $this->data['branches'][count($this->data['branches'])] = array(
                        "id" => $this->brach_id++,
                        "uid" => $this->branch_uid++,
                        "active" => true,
                        "sticky" => true,
-                       "name" => array($name),
+                       "name" => $name_arr,
                        "next" => $first_id,
                        "pre_merge" => false
                );
@@ -147,7 +150,7 @@ class graph_data_generator {
                                $branch['active'] = false;
                                $commit['dot_type'] = self::DOT_TYPE_INIT;
                        }
-                       $branch['next'] = (array_key_exists('parent', $commit) ? $commit['parent'][0] : null);
+                       $branch['next'] = ((array_key_exists('parent', $commit) && count($commit['parent'])) ? $commit['parent'][0] : null);
                        $branch['pre_merge'] = false;
                        $this->data['ubranches'][$branch['uid']] = $this->data['branches'][$branch['id']-1];
                        
@@ -255,7 +258,7 @@ class graph_data_generator {
                foreach($this->data['branches'] as $branch) {
                        if(array_key_exists('sticky', $branch) && $branch['sticky']) {
                                $name = explode('/', $branch['name'][0], 3);
-                               $dataadd .= "\n".$branch['id'].":".$name[2];
+                               $dataadd .= "//".$branch['id'].":".$name[2];
                                $branchcount++;
                        }
                }
@@ -295,8 +298,10 @@ class graph_image_generator {
                if(!GitConfig::GITGRAPH_ENABLE)
                        return;
                $data = $this->parse_data($data);
-               if(!$data)
-                       return;
+               if(!$data) {
+                       header('Content-Type: text/plain');
+                       die(base64_decode("ICAgIC0tLS0tLS0tOi0tLS0tLS0tDQogICAgICAgICAgLC0iLC5fX19fX19fIC8NCiAgICAgICAgIC8gKSB8ICAgLC0tLS0nXA0KICAgICAgICAgXC9fX3wuLSINCiAgICAgICAgLl8vL19cXF8NCk5vdCB3aGF0IHlvdSBleHBlY3RlZCwgZWVlaD8="));
+               }
                
                $count = $data['count'];
                if($count > $this->max_branches)
@@ -315,7 +320,7 @@ class graph_image_generator {
        }
        
        private function display_header($header) {
-               $header = explode("\n",$header);
+               $header = explode("//",$header);
                $count = $header[0];
                $header = array_slice($header, 1);
                if($count > $this->max_branches)
@@ -347,6 +352,7 @@ class graph_image_generator {
                header('Content-Type: image/png');
                imagepng($image);
                imagedestroy($image);
+               die();
        }
        
        private function parse_data($data) {