[Core] Fix notice of undefined offset when in detached HEAD state. (#1569)

This commit is contained in:
Michael Bemmerl 2020-05-27 21:08:06 +00:00 committed by GitHub
parent a1dd98ff82
commit c4422bdbb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 3 deletions

View File

@ -244,9 +244,13 @@ final class Configuration {
if(@is_readable($headFile)) {
$revisionHashFile = '.git/' . substr(file_get_contents($headFile), 5, -1);
$branchName = explode('/', $revisionHashFile)[3];
if(file_exists($revisionHashFile)) {
return 'git.' . $branchName . '.' . substr(file_get_contents($revisionHashFile), 0, 7);
$parts = explode('/', $revisionHashFile);
if(isset($parts[3])) {
$branchName = $parts[3];
if(file_exists($revisionHashFile)) {
return 'git.' . $branchName . '.' . substr(file_get_contents($revisionHashFile), 0, 7);
}
}
}