From: Kevin Israel Date: Sun, 3 Feb 2013 00:11:28 +0000 (-0500) Subject: Show HEADs for Git 1.7.8+ submodules X-Git-Tag: 1.31.0-rc.0~20626 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/categories/modifier.php?a=commitdiff_plain;h=e951be59c60a70dd442d10acb4f6e1064967e345;p=lhc%2Fweb%2Fwiklou.git Show HEADs for Git 1.7.8+ submodules I implemented "the gitfile mechanism" in the GitInfo class so it can access gitdirs for submodules again. Bug: 44599 Change-Id: Ieb79c0b401a6bb0f5ca8bff98bb382a8c6ffbb01 --- diff --git a/RELEASE-NOTES-1.21 b/RELEASE-NOTES-1.21 index 34030beabc..6e811fc71e 100644 --- a/RELEASE-NOTES-1.21 +++ b/RELEASE-NOTES-1.21 @@ -173,6 +173,8 @@ production. URL without address * (bug 45012) Creating an account by e-mail can no longer show a "password mismatch" error. +* (bug 44599) On Special:Version, HEADs for submodule checkouts (e.g. for + extensions) performed using Git 1.7.8+ should now appear. === API changes in 1.21 === * prop=revisions can now report the contentmodel and contentformat. diff --git a/includes/GitInfo.php b/includes/GitInfo.php index c3c307336e..a0a216ee58 100644 --- a/includes/GitInfo.php +++ b/includes/GitInfo.php @@ -44,7 +44,15 @@ class GitInfo { * @param $dir string The root directory of the repo where the .git dir can be found */ public function __construct( $dir ) { - $this->basedir = "{$dir}/.git/"; + $this->basedir = "{$dir}/.git"; + if ( is_readable( $this->basedir ) ) { + $GITfile = file_get_contents( $this->basedir ); + if ( strlen( $GITfile ) > 8 && substr( $GITfile, 0, 8 ) === 'gitdir: ' ) { + $path = rtrim( substr( $GITfile, 8 ), "\r\n" ); + $isAbsolute = $path[0] === '/' || substr( $path, 1, 1 ) === ':'; + $this->basedir = $isAbsolute ? $path : "{$dir}/{$path}"; + } + } } /** @@ -102,7 +110,7 @@ class GitInfo { } // If not a SHA1 it may be a ref: - $REFfile = "{$this->basedir}{$HEAD}"; + $REFfile = "{$this->basedir}/{$HEAD}"; if ( !is_readable( $REFfile ) ) { return false; }