From 2876b7014e41a5f41f8a1a6a1997e6ffbd3a7c50 Mon Sep 17 00:00:00 2001 From: Kasun Chathuranga Date: Wed, 10 Apr 2013 23:59:33 +0530 Subject: [PATCH 1/3] Fix bug #3860 Displayed git revision info is not set --- libraries/Config.class.php | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/libraries/Config.class.php b/libraries/Config.class.php index 514ef2c6cd..8b115d8c00 100644 --- a/libraries/Config.class.php +++ b/libraries/Config.class.php @@ -462,22 +462,31 @@ class PMA_Config $commit = explode("\n", $commit[1]); $_SESSION['PMA_VERSION_COMMITDATA_' . $hash] = $commit; } else { + $pack_names = array(); // work with packed data - if (! $packs = @file_get_contents($git_folder . '/objects/info/packs')) { - return; + if ($packs = @file_get_contents($git_folder . '/objects/info/packs')) { + foreach (explode("\n", $packs) as $line) { + // skip blank lines + if (strlen(trim($line)) == 0) { + continue; + } + // skip non pack lines + if ($line[0] != 'P') { + continue; + } + $pack_names[] = substr($line, 2); + } + } else { + $it = new DirectoryIterator($git_folder . '/objects/pack'); + foreach ($it as $file_info) { + $file_name = $file_info->getFilename(); + if ($file_info->isFile() && substr($file_name, -5) == '.pack') { + $pack_names[] = $file_name; + } + } } $hash = strtolower($hash); - foreach (explode("\n", $packs) as $line) { - // skip blank lines - if (strlen(trim($line)) == 0) { - continue; - } - // skip non pack lines - if ($line[0] != 'P') { - continue; - } - // parse names - $pack_name = substr($line, 2); + foreach ($pack_names as $pack_name) { $index_name = str_replace('.pack', '.idx', $pack_name); // load index From 224100dd8ab3a1bbc9ec323c13ddce06c20e2fcd Mon Sep 17 00:00:00 2001 From: Kasun Chathuranga Date: Thu, 11 Apr 2013 00:15:35 +0530 Subject: [PATCH 2/3] Add ChangeLog entry for the bug fix --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 0f44b2b627..19d5088e05 100644 --- a/ChangeLog +++ b/ChangeLog @@ -102,6 +102,7 @@ underscore - bug #3703 Incorrect updating of the list of users - bug #3853 Blowfish implementation might be broken (replace with phpseclib) - bug #3865 Using like operator on each backslash needs 4 backslash protection +- bug #3860 Displayed git revision info is not set 3.5.9.0 (not yet released) From 57e751ff96c661fcf809f1af05df2ee8ce1b1f5e Mon Sep 17 00:00:00 2001 From: Kasun Chathuranga Date: Thu, 11 Apr 2013 06:50:16 +0530 Subject: [PATCH 3/3] Add comments describing the changes --- libraries/Config.class.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/libraries/Config.class.php b/libraries/Config.class.php index 8b115d8c00..992d268f55 100644 --- a/libraries/Config.class.php +++ b/libraries/Config.class.php @@ -465,6 +465,8 @@ class PMA_Config $pack_names = array(); // work with packed data if ($packs = @file_get_contents($git_folder . '/objects/info/packs')) { + // File exists. Read it, parse the file to get the names of the + // packs. (to look for them in .git/object/pack directory later) foreach (explode("\n", $packs) as $line) { // skip blank lines if (strlen(trim($line)) == 0) { @@ -474,13 +476,22 @@ class PMA_Config if ($line[0] != 'P') { continue; } + // parse names $pack_names[] = substr($line, 2); } } else { + // '.git/objects/info/packs' file can be missing + // (atlease in mysGit) + // File missing. May be we can look in the .git/object/pack + // directory for all the .pack files and use that list of + // files instead $it = new DirectoryIterator($git_folder . '/objects/pack'); foreach ($it as $file_info) { $file_name = $file_info->getFilename(); - if ($file_info->isFile() && substr($file_name, -5) == '.pack') { + // if this is a .pack file + if ($file_info->isFile() + && substr($file_name, -5) == '.pack' + ) { $pack_names[] = $file_name; } }