X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;ds=sidebyside;f=includes%2FGitInfo.php;h=3c600ed984057918d3a7f8c2bb07af0797e8bcbc;hb=a8379682a46a428320c88702c800a6107c015137;hp=de7e8c28e2d8373af10bbe253b696f1daaf11573;hpb=57eaa2bf04ce1b48bd89c10defe4de5b7d31f047;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/GitInfo.php b/includes/GitInfo.php index de7e8c28e2..3c600ed984 100644 --- a/includes/GitInfo.php +++ b/includes/GitInfo.php @@ -46,7 +46,7 @@ class GitInfo { protected $cache = []; /** - * Map of repo URLs to viewer URLs. Access via static method getViewers(). + * @var array|false Map of repo URLs to viewer URLs. Access via static method getViewers(). */ private static $viewers = false; @@ -191,8 +191,14 @@ class GitInfo { } else { // If not a SHA1 it may be a ref: $refFile = "{$this->basedir}/{$head}"; + $packedRefs = "{$this->basedir}/packed-refs"; + $headRegex = preg_quote( $head, '/' ); if ( is_readable( $refFile ) ) { $sha1 = rtrim( file_get_contents( $refFile ) ); + } elseif ( is_readable( $packedRefs ) && + preg_match( "/^([0-9A-Fa-f]{40}) $headRegex$/m", file_get_contents( $packedRefs ), $matches ) + ) { + $sha1 = $matches[1]; } } $this->cache['headSHA1'] = $sha1;