Git 网页界面

发布于 2024-08-08 11:02:27 字数 1612 浏览 2 评论 0原文

我正在尝试使 viewgit 界面适用于我的项目。

然而,我在 PHP exec 中遇到了这个奇怪的问题:

这两个 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 是空的!

关于造成这种情况的原因有什么想法吗?

谢谢

I am trying to make the viewgit interface work for my projects.

However I am running into this curious issue with PHP exec:

These 2 unix commands work from inside my viewgit/ directory:

/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

and

/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();

however when using php exec only the first one returns an output:

$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 does infact contain the data from the command line ... however, $output_2 is empty !

Any ideas on what is causing this ?

Thx

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

病毒体 2024-08-15 11:02:27

经过一番懊恼之后,我终于找到了一个解决方案......逃避^。

所以我深入研究了代码并替换为:

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

其他地方可能存在类似的问题,但

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

仍然没有解决它们。

After much chagrin I finally landed on a solution....escape the ^.

So I digged into the code and replaced:

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

with

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

there might be similar problems elsewhere, still haven't landed on them yet.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文