PHP exec输出是缩写和剪切

时间:2017-03-30 02:51:42

标签: php git exec

我尝试捕获git日志文件的输出

shell

/usr/bin/git log --stat --pretty=format:%an*_*%cd*_*%H*_*%s

输出

rrr*_*Wed Mar 29 15:03:44 2016 +0800*_*51c32954639dffbdba18050527ca56b0ec243453*_*bug#1395
 mine-web-manage/src/main/webapp/WEB-INF/views/organ/courseForm.jsp                                         |  6 +++++-
 mine-web-server/src/main/java/com/mine/web/server/controller/organ/RestPublicOrganTeacherController.java | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+), 1 deletion(-)

但是使用php exec,字符串被截断

代码

$cmd = "/usr/bin/git log --stat --pretty=format:%an*_*%cd*_*%H*_*%s";
exec($cmd, $list, $return);
var_dump($list);

输出

  string(90) "rrr*_*Wed Mar 29 15:03:44 2016 +0800*_*51c32954639dffbdba18050527ca56b0ec243453*_*bug#1395"
  [18] =>
  string(60) " .../main/webapp/WEB-INF/views/organ/courseForm.jsp |  6 ++-"
  [19] =>
  string(79) " .../organ/RestPublicOrganTeacherController.java    | 53 ++++++++++++++++++++++"
  [20] =>
  string(49) " 2 files changed, 58 insertions(+), 1 deletion(-)"

我尝试了以下方法,一切都行不通,结果全部切断了

1, $cmd . " 2>&1"
2, $cmd . " > /tmp/cmd.txt"
3, passthru($cmd, $list, $return);

我想在输出中获得完整的字符串

任何人都对发生的事情有所了解?

非常感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

使用代码很好

git log  --stat=200 --pretty=format:%an*_*%cd*_*%H*_*%s

show full file path in git log