From 6ebd99717b1fa67217d6ee6c05415082ba40eb02 Mon Sep 17 00:00:00 2001 From: zhaoke Date: Wed, 23 Aug 2023 11:14:44 +0800 Subject: [PATCH] * Fix diff page empty when revision is first commit. --- lib/scm/gitrepo.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/scm/gitrepo.class.php b/lib/scm/gitrepo.class.php index ad805caf62..1fd46f4fbe 100644 --- a/lib/scm/gitrepo.class.php +++ b/lib/scm/gitrepo.class.php @@ -310,7 +310,9 @@ class GitRepo if(strpos($fromRevision, '^') !== false) { $list = execCmd(escapeCmd("$this->client log -2 $toRevision --pretty=format:%H -- $path"), 'array'); - if(isset($list[1])) $fromRevision = $list[1]; + if(!isset($list[1])) return execCmd(escapeCmd("$this->client show HEAD"), 'array'); + + $fromRevision = $list[1]; } $lines = execCmd(escapeCmd("$this->client diff $fromRevision $toRevision -- $path"), 'array'); return $lines;