X-Git-Url: http://git.pk910.de/?p=phpgitweb.git;a=blobdiff_plain;f=htdocs%2Flib%2FPageClasses.diff.class.php;fp=htdocs%2Flib%2FPageClasses.diff.class.php;h=f02fb4607dcd2314be163ddddd97bae5a5628261;hp=ff53a204309974653e8bc4927f7359564c68556d;hb=07f0862d6ef4a14a812381a30931a46a51dbc87d;hpb=5a1b314c0a0ab8ed9be7b857c7996d8a3f87e7ed diff --git a/htdocs/lib/PageClasses.diff.class.php b/htdocs/lib/PageClasses.diff.class.php index ff53a20..f02fb46 100644 --- a/htdocs/lib/PageClasses.diff.class.php +++ b/htdocs/lib/PageClasses.diff.class.php @@ -77,6 +77,12 @@ class diff { break; } while(true); } + if($patch_id == 1) { + if(count($commit['parent']) > 1) + $html[] = new ContentProvider('commitdiff', 'patch_nopatch_merge'); + else + $html[] = new ContentProvider('commitdiff', 'patch_nopatch_simple'); + } return $html; } @@ -152,6 +158,37 @@ class diff { return $header; } + private function format_line($line) { + $lineobj = new ContentProvider('commitdiff', 'patch_diffline'); + $class = ""; + if($this->tree['parents'] > 1) { + $prefix = substr($line, 0, $this->tree['parents']); + if(preg_match('/@/', $prefix)) + $class = " chunk_header"; + else if(preg_match('/\\/', $prefix)) + $class = " incomplete"; + else if(preg_match('/+/', $prefix)) + $class = " add"; + else if(preg_match('/-/', $prefix)) + $class = " rem"; + } else { + $prefix = substr($line, 0, 1); + if($prefix == '@') + $class = " chunk_header"; + else if($prefix == '\\') + $class = " incomplete"; + else if($prefix == '+') + $class = " add"; + else if($prefix == '-') + $class = " rem"; + } + $lineobj->set('class', $class); + $line = Tools::replaceTabs($line); + $lineobj->set('line', htmlentities($line)); + + return $lineobj; + } + private function gen_contentprovider($patch_id) { if(!$this->diff) $pageclass = 'patch_nodiff'; @@ -161,6 +198,7 @@ class diff { $pageclass = 'patch_normal'; $page = new ContentProvider('commitdiff', $pageclass); $page->set('diffcmd', $this->gen_diffcmd_header()); + $page->set('patch_id', $patch_id); if(!$this->diff) return $page; $is_header = true; @@ -178,8 +216,8 @@ class diff { continue; } } - $lineobj = new ContentProvider('commitdiff', 'patch_diffline'); - //if(preg_match('', $line)) + $page->append('patch', $this->format_line($line)); + } if($is_header) $page->set('patch', '');