git::ls_staged PHP Method

ls_staged() static public method

static public ls_staged ( $paths = null )
    static function ls_staged($paths = null)
    {
        $paths = self::escargs($paths);
        $ls = rtrim(self::exec('ls-files --stage -t -z -- ' . $paths));
        $files = array();
        if ($ls) {
            # Iterate objects
            $ls = explode("", $ls);
            foreach ($ls as $line) {
                # <status char> SP <mode> SP <object> SP <stage no> TAB <name>
                if (!$line) {
                    continue;
                }
                $file = (object) array('status' => null, 'id' => null, 'name' => null);
                $line = explode(' ', $line, 4);
                $file->status = $line[0];
                $file->id = $line[2];
                $file->name = gb_normalize_git_name(substr($line[3], strpos($line[3], "\t") + 1));
                $files[] = $file;
            }
        }
        return $files;
    }