diff --git a/src/PHPGit/Command/BranchCommand.php b/src/PHPGit/Command/BranchCommand.php index 4b42f50..3c83478 100644 --- a/src/PHPGit/Command/BranchCommand.php +++ b/src/PHPGit/Command/BranchCommand.php @@ -66,17 +66,25 @@ public function __invoke(array $options = array()) $branch = array(); preg_match('/(?\*| ) (?[^\s]+) +((?:->) (?[^\s]+)|(?[0-9a-z]{7}) (?.*))/', $line, $matches); - $branch['current'] = ($matches['current'] == '*'); - $branch['name'] = $matches['name']; + if(!empty($matches['current'])){ + $branch['current'] = ($matches['current'] == '*'); + }else{ + $branch['current'] = null; + } + + $branch['name'] = !empty($matches['name']) ? $matches['name'] : null; if (isset($matches['hash'])) { $branch['hash'] = $matches['hash']; $branch['title'] = $matches['title']; } else { - $branch['alias'] = $matches['alias']; + $branch['alias'] = !empty($matches['alias']) ? $matches['alias'] : null; + } + + if(!empty($matches['name'])){ + $branches[$matches['name']] = $branch; } - $branches[$matches['name']] = $branch; } return $branches;