composer/composer — pull request #2188 by Danack (2013-08-18 22:55:17+00:00)
Title: Find root composer.json in zip artifact more reliably.

ZipArchive::locateName() finds the first file that matches the name in the zip file. If a zip file has multiple composer.json files in it, locateName() is not guaranteed to find the one in the root directory. http://www.php.net/manual/en/ziparchive.locatename.php#85512

e.g. the project https://github.com/maximebf/php-debugbar has a composer.json file in the sub-directory
https://github.com/maximebf/php-debugbar/tree/master/demo/bridge/cachecache which is not meant to be used as the composer.json for the project.

The patch makes the finding of the composer.json be more reliable, as it find the one that has the shortest total path, which should be the one in the root folder.