From 3b98f5db0c13330d783291a01339bd86a999038b Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Sun, 29 Nov 2015 16:41:43 +0100 Subject: [PATCH] Fixes an issue with stats in paths with whitespace Splitting on whitespace of the ls-tree output is not enough: when a path contains a space only the first part is taken as the file name. This commit changes that behaviour by using another command to list all the file names. --- src/Git/Repository.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Git/Repository.php b/src/Git/Repository.php index 58338fb..ca2d087 100644 --- a/src/Git/Repository.php +++ b/src/Git/Repository.php @@ -344,9 +344,13 @@ class Repository extends BaseRepository if (is_numeric($file[3])) { $data['size'] += $file[3]; } + } - if (($pos = strrpos($file[4], '.')) !== false) { - $extension = substr($file[4], $pos); + $logs = $this->getClient()->run($this, 'ls-tree -l -r --name-only ' . $branch); + $files = explode("\n", $logs); + foreach ($files as $file) { + if (($pos = strrpos($file, '.')) !== false) { + $extension = substr($file, $pos); if (($pos = strrpos($extension, '/')) === false) { $data['extensions'][] = $extension;