2009-10-19 87 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); 

可能存在类似的问题在其他地方,仍然没有降落在他们没有。