Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Caching diff files added.

  • Loading branch information...
commit df542e340a477a7871e904aa001f852231133419 1 parent 0c7c9ea
@xanmanning xanmanning authored
Showing with 17 additions and 5 deletions.
  1. +17 −5 git.php
View
22 git.php
@@ -421,11 +421,23 @@ function html_diff($proj, $commit) {
//$c = git_commit($proj, $commit);
$c['parent'] = $_GET['hb'];
$out = array();
- exec("GIT_DIR=" . escapeshellarg($repopath . $CONFIG['repo_suffix']) . " git diff " . escapeshellarg($c['parent']) . " " .
- escapeshellarg($commit) . " 2>&1", &$out);
- $out = implode("\n", $out);
- $out = geshi_highlight($out, 'diff');
- $out = geshi_style() . $out;
+ $geshiCache = $CONFIG['cache_directory'] . $proj . "/diff-" . $commit;
+ if(!file_exists($geshiCache)) {
+ exec("GIT_DIR=" . escapeshellarg($repopath . $CONFIG['repo_suffix']) . " git diff " . escapeshellarg($c['parent']) . " " .
+ escapeshellarg($commit) . " 2>&1", &$out);
+ $out = implode("\n", $out);
+ $out = geshi_highlight($out, 'diff');
+ $out = geshi_style() . $out;
+ $fp = fopen($geshiCache, "w");
+ fwrite($fp, $out);
+ fclose($fp);
+ chmod($geshiCache, 0666);
+ } else {
+ $fp = fopen($geshiCache, "r");
+ $out = fread($fp, filesize($geshiCache) + 1024);
+ fclose($fp);
+ }
+
echo "<div class=\"gitcode\">\n";
echo $out;
echo "</div>\n";
Please sign in to comment.
Something went wrong with that request. Please try again.