major refactoring under the hood
[pharext/pharext] / src / pharext / SourceDir / Git.php
index a16b1e67769726e26c912b7d9883edcd2635dca9..8e35bf9b3f50fb292501f6c02652f090397685e8 100644 (file)
@@ -46,16 +46,18 @@ class Git implements \IteratorAggregate, SourceDir
        private function generateFiles() {
                $pwd = getcwd();
                chdir($this->path);
-               if (($pipe = popen("git ls-files", "r"))) {
+               if (($pipe = popen("git ls-tree -r --name-only HEAD", "r"))) {
+                       $path = realpath($this->path);
                        while (!feof($pipe)) {
                                if (strlen($file = trim(fgets($pipe)))) {
                                        if ($this->cmd->getArgs()->verbose) {
                                                $this->cmd->info("Packaging %s\n", $file);
                                        }
-                                       if (!($realpath = realpath($file))) {
-                                               $this->cmd->error("File %s does not exist\n", $file);
+                                       /* there may be symlinks, so no realpath here */
+                                       if (!file_exists("$path/$file")) {
+                                               $this->cmd->warn("File %s does not exist in %s\n", $file, $path);
                                        }
-                                       yield $realpath;
+                                       yield "$path/$file";
                                }
                        }
                        pclose($pipe);