X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=htdocs%2Flib%2FGitCommand.class.php;h=198cc61f6ce166f5e7fcbe78d2dd7be7ee0fb13e;hb=45f97c3c11bdffe296ccfc853621fd2fff1732a1;hp=a8ede915817beaafc0e070ddcb8027248bd8ae2a;hpb=38cb4c7eb8706a5e500957185493e2025fde5dc1;p=phpgitweb.git diff --git a/htdocs/lib/GitCommand.class.php b/htdocs/lib/GitCommand.class.php index a8ede91..198cc61 100644 --- a/htdocs/lib/GitCommand.class.php +++ b/htdocs/lib/GitCommand.class.php @@ -68,8 +68,10 @@ class GitCommand { if($ref) $args[] = $ref; $age = self::git_execute($args, $git_path); - preg_match("/[0-9]{9,}/i", $age, $result); - return $result[0]; + if(preg_match("/[0-9]{9,}/i", $age, $result)) + return $result[0]; + else + return -1; } private static function parse_commit($commit_data) { @@ -124,7 +126,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 +155,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; }