2009-10-19 89 views
2

我想讓viewgit接口爲我的項目工作。Git Web界面

但是我遇到了這個奇怪的問題,與PHP的exec:

這2個UNIX從我viewgit /目錄內的命令工作:

 
/viewgit-> GIT_DIR=/usr/local/apache2/htdocs/repo/.git git rev-list --header --max-count=1 c19e231ad87413798b6a1387a98ec814836fda1e 
19e231ad87413798b6a1387a98ec814836fda1e 
c19e231ad87413798b6a1387a98ec814836fda1e 
tree 4351aa5fb93c3a093902577e5a58138280851152 
parent 5099ea6747f8b8a532d153f0536e7be956532a33 
author John.smith514-490-6597 1255981013 -0400 
committer John.Smith514-490-6597 1255981013 -0400 

 
/viewgit-> GIT_DIR=/usr/local/apache2/htdocs/repo/.git git diff c19e231ad87413798b6a1387a98ec814836fda1e^..c19e231ad87413798b6a1387a98ec814836fda1e 
diff --git a/bootstrap.php b/bootstrap.php 
index 6cc6336..857890b 100755 
--- a/bootstrap.php 
+++ b/bootstrap.php 
@@ -17,7 +17,7 @@ 
     );    

     // ZEND LIBRARY 
-  //-------------------------------------- 
+  //--------------------------------------- 
     // 1.7 
     //require_once "Zend/Loader.php"; 
     //Zend_Loader::registerAutoload(); 

然而,當使用php exec只有第一個返回輸出:

 
$output_1 = array(); 
$output_2 = array(); 
$cmd_1 = "GIT_DIR=/usr/local/apache2/htdocs/repo/.git git rev-list --header --max-count=1 c19e231ad87413798b6a1387a98ec814836fda1e"; 
$cmd_2 = "GIT_DIR=/usr/local/apache2/htdocs/repo/.git git diff c19e231ad87413798b6a1387a98ec814836fda1e^..c19e231ad87413798b6a1387a98ec814836fda1e"; 
exec($cmd_1, $output_1, $ret); 
exec($cmd_2, $output_2, $ret); 

$ output_1確實包含命令行中的數據......但是,$ output_2是空的!

什麼是造成這種情況的任何想法?

THX

+0

好像它可能是一個權限問題的地方,但不能完全找到它 – ddallala 2009-10-20 14:39:04

+0

以及我一直在做一些頭部的方式,已登錄爲'守護進程'並直接從shell運行命令cmd_2沒有工作! 它看起來像^指定提交標識符正在導致守護進程執行後面的內容,因此在這種情況下:..c19e231ad87413798b6a1387a98ec814836fda1e – ddallala 2009-10-20 15:00:35

回答

2

多少懊惱之後,我終於想到了一個解決方案....逃脫^。

所以我挖成的代碼代替:

 
$text = git_diff($page['project'], "$hash^", $hash); 

 
$text = git_diff($page['project'], "$hash\^", $hash); 

可能存在類似的問題在其他地方,仍然沒有降落在他們沒有。