Merge "Skin: Make skins aware of their registered skin name"
[lhc/web/wiklou.git] / includes / GitInfo.php
index de7e8c2..3c600ed 100644 (file)
@@ -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;