Check for valid git repository in GitInfo::getHeadCommitDate
authorBryan Davis <bd808@wikimedia.org>
Tue, 6 May 2014 19:15:09 +0000 (13:15 -0600)
committerBryan Davis <bd808@wikimedia.org>
Tue, 6 May 2014 19:19:43 +0000 (13:19 -0600)
Ensure that GitInfo::getHead returns a valid value before attempting to
use the git binary to extract a commit date.

Bug: 64948
Change-Id: Ib0d245306842706dbb5d4b9522bb381a5f55526c

includes/GitInfo.php

index dc2fff1..304c1bc 100644 (file)
@@ -195,7 +195,10 @@ class GitInfo {
 
                if ( !isset( $this->cache['headCommitDate'] ) ) {
                        $date = false;
-                       if ( is_file( $wgGitBin ) && is_executable( $wgGitBin ) ) {
+                       if ( is_file( $wgGitBin ) &&
+                               is_executable( $wgGitBin ) &&
+                               $this->getHead() !== false
+                       ) {
                                $environment = array( "GIT_DIR" => $this->basedir );
                                $cmd = wfEscapeShellArg( $wgGitBin ) .
                                        " show -s --format=format:%ct HEAD";