started diff parser
[phpgitweb.git] / htdocs / lib / GitCommand.class.php
index a8ede915817beaafc0e070ddcb8027248bd8ae2a..86174b5e6e29551eba91a7757378208d913fe9eb 100644 (file)
@@ -124,7 +124,7 @@ class GitCommand {
        }
        
        public static function get_commit($git_path, $commit_id) {
-               $args = array("rev-list", "--header", "--max-count=1", $commit_id, "--");
+               $args = array("rev-list", "--header", "--max-count=1", ($commit_id ? $commit_id : "--all"), "--");
                $commit_data = self::git_execute($args, $git_path);
                $commit = self::parse_commit($commit_data);
                return $commit;
@@ -153,17 +153,18 @@ class GitCommand {
                                $files = explode("\t", $entry['file']);
                                $entry['from_file'] = $files[0];
                                $entry['to_file'] = $files[1];
-                       }
+                       } else
+                               $entry['from_file'] = $entry['to_file'] = $entry['file'];
                } else if(preg_match('/^(::+)((?:[0-7]{6} )+)((?:[0-9a-fA-F]{40} )+)([a-zA-Z]+)\t(.*)$/i', $line, $matches)) {
                        $entry['parents'] = strlen($matches[1]);
                        $from_modes = explode(" ", $matches[2]);
-                       $entry['from_mode'] = array_slice($from_modes, 1);
+                       $entry['from_mode'] = array_slice($from_modes, 1, -1);
                        $entry['to_mode'] = $from_modes[0];
                        $from_ids = explode(" ", $matches[3]);
-                       $entry['from_id'] = array_slice($from_ids, 1);
+                       $entry['from_id'] = array_slice($from_ids, 1, -1);
                        $entry['to_id'] = $from_ids[0];
                        $entry['status'] = str_split($matches[4]);
-                       $entry['file'] = $matches[5];
+                       $entry['file'] = $entry['from_file'] = $entry['to_file'] = $matches[5];
                }
                return $entry;
        }