<?php

error_reporting(-1);

chdir('d:/sources/minetest');

$git = popen('git rev-list --all | git cat-file --batch', 'rb');

$data = array();

while (($s = fgets($git)) !== FALSE) {
	if (!preg_match('/^(?P<hash>[0-9a-f]{40}) (?P<type>[a-z]+) (?P<size>\d+)$/', $s, $m)) {
		throw new Exception("Unexpected format: *$s*");
	};

	$current = array(
		'hash' => $m['hash'],
		'type' => $m['type'],
		'data' => fread($git, $m['size']),
	);


	//print_r($current);

	$data[] = $current;

	fgets($git);
}

pclose($git);

print_r($data);

