Properly pipe git_history_list
Properly pipe git_history_list

--- a/include/display.git_history.php
+++ b/include/display.git_history.php
@@ -30,7 +30,8 @@
 	$tpl->display("history_header.tpl");
 	$cmdout = git_history_list($projectroot . $project, $hash, $file);
 	$alternate = FALSE;
-	foreach ($cmdout as $i => $line) {
+	$lines = explode("\n", $cmdout);
+	foreach ($lines as $i => $line) {
 		if (ereg("^([0-9a-fA-F]{40})",$line,$regs))
 			$commit = $regs[1];
 		else if (ereg(":([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$",$line,$regs) && isset($commit)) {

--- a/include/gitutil.git_history_list.php
+++ b/include/gitutil.git_history_list.php
@@ -12,16 +12,9 @@
 
 function git_history_list($proj,$hash,$file)
 {
-	$list = array();
-	$cmd = GIT_REV_LIST . " " . $hash;
-	$out = git_exec($proj, $cmd);
-	$outlist = explode("\n",$out);
-	foreach ($outlist as $i => $line) {
-		$out2 = git_exec($proj, GIT_DIFF_TREE . " -r " . $line . " '" . $file . "'");
-		$out2list = explode("\n",$out2);
-		$list = array_merge($list, $out2list);
-	}
-	return $list;
+	global $gitphp_conf;
+	$cmd = GIT_REV_LIST . " " . $hash . " | " . $gitphp_conf['gitbin'] . " --git-dir=" . $proj . " " . GIT_DIFF_TREE . " -r --stdin -- " . $file;
+	return git_exec($proj, $cmd);
 }
 
 ?>

comments