Explorar o código

Minor robustness fix

Jordi Boggiano %!s(int64=12) %!d(string=hai) anos
pai
achega
3aeb6a8f2d
Modificáronse 1 ficheiros con 3 adicións e 2 borrados
  1. 3 2
      src/Composer/Repository/Vcs/GitDriver.php

+ 3 - 2
src/Composer/Repository/Vcs/GitDriver.php

@@ -165,8 +165,9 @@ class GitDriver extends VcsDriver
             $this->process->execute('git branch --no-color --no-abbrev -v', $output, $this->repoDir);
             foreach ($this->process->splitLines($output) as $branch) {
                 if ($branch && !preg_match('{^ *[^/]+/HEAD }', $branch)) {
-                    preg_match('{^(?:\* )? *(?:[^/ ]+?/)?(\S+) *([a-f0-9]+) .*$}', $branch, $match);
-                    $branches[$match[1]] = $match[2];
+                    if (preg_match('{^(?:\* )? *(?:[^/ ]+?/)?(\S+) *([a-f0-9]+) .*$}', $branch, $match)) {
+                       $branches[$match[1]] = $match[2];
+                    }
                 }
             }