From d981ec0fe9764d30e00cc773de048a094e19b679 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Sun, 27 Jul 2008 01:19:25 -0600 Subject: [PATCH] Improve command line code to pull everything at once. Signed-off-by: Edward Z. Yang --- library/Git.php | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/library/Git.php b/library/Git.php index 25f85ad..ac91fa5 100644 --- a/library/Git.php +++ b/library/Git.php @@ -100,29 +100,19 @@ class Git ); $pipes = array(); $proc = proc_open($command, $pipes_template, $pipes); + // Input fwrite($pipes[0], $istream); fclose($pipes[0]); - $stderr = $stdout = ''; - while (true) { - $read = array($pipes[1]); - $except = $write = null; - $n = stream_select($read, $write, $except, 30); - if ($n === 0) { - throw new Git_Exception('Process timed out'); - } elseif ($n > 0) { - $errLine = fread($pipes[2], 8192); - $outLine = fread($pipes[1], 8192); - $stderr .= $errLine; - $stdout .= $outLine; - if ($errLine === '' && $outLine === '') { - fclose($pipes[1]); - fclose($pipes[2]); - break; - } - } - } + // Output + $stdout = stream_get_contents($pipes[1]); + fclose($pipes[1]); + // Error + $stderr = stream_get_contents($pipes[2]); + fclose($pipes[2]); + // Status $status = trim(fread($pipes[3], 5)); fclose($pipes[3]); + // Cleanup $close = proc_close($proc); if (empty($code)) $status = $close; } -- 2.11.4.GIT