diff --git a/src/Composer/Command/DiagnoseCommand.php b/src/Composer/Command/DiagnoseCommand.php
index ce5488291..97ecf1c6b 100644
--- a/src/Composer/Command/DiagnoseCommand.php
+++ b/src/Composer/Command/DiagnoseCommand.php
@@ -21,6 +21,7 @@ use Composer\Repository\PlatformRepository;
use Composer\Plugin\CommandEvent;
use Composer\Plugin\PluginEvents;
use Composer\Util\ConfigValidator;
+use Composer\Util\Git;
use Composer\Util\IniHelper;
use Composer\Util\ProcessExecutor;
use Composer\Util\HttpDownloader;
@@ -225,10 +226,7 @@ EOT
return true;
}
- /**
- * @return string|true
- */
- private function checkGit()
+ private function checkGit(): string
{
if (!function_exists('proc_open')) {
return 'proc_open is not available, git cannot be used';
@@ -239,7 +237,16 @@ EOT
return 'Your git color.ui setting is set to always, this is known to create issues. Use "git config --global color.ui true" to set it correctly.';
}
- return true;
+ $gitVersion = Git::getVersion($this->process);
+ if (version_compare('2.24.0', $gitVersion, '>')) {
+ return 'Your git version ('.$gitVersion.') is too old and possibly will cause issues. Please upgrade to git 2.24 or above>';
+ }
+
+ if (null === $gitVersion) {
+ return 'No git process found>';
+ }
+
+ return 'OK> git version '.$gitVersion.'>';
}
/**