Subversion Repositories php_utils

Compare Revisions

Regard whitespace Rev 77 → Rev 78

/trunk/git_utils.inc.php
141,6 → 141,7
 
if ($version == 2) {
// Get CRC32
// TODO: is this correct? or do we need to read 'H8' ?
fseek($fp, $fanout_offset + 4*256 + 20*$num_objects + 4*$object_no);
$crc32 = unpack('N', fread($fp,4))[1];
if ($debug) echo "CRC32 = ".sprintf('0x%08x',$crc32)."\n";
175,7 → 176,7
fseek($fp, $pack_offset);
$size_info = unpack('C', fread($fp,1))[1];
 
$type = ($size_info & 0xE0) >> 5; /*0b11100000*/
$type = ($size_info & 0x70) >> 4; /*0b01110000*/
switch ($type) {
case 1:
if ($debug) echo "Type = OBJ_COMMIT ($type)\n";
201,21 → 202,31
}
 
// Find out size
$size = $size_info & 0x1F /*0x00011111*/;
$shift_info = 5;
do {
$size = $size_info & 0xF /*0x00001111*/;
$shift_info = 4;
while ($size_info >= 0x80) {
$size_info = unpack('C', fread($fp,1))[1];
$size = (($size_info & 0x7F) << $shift_info) + $size;
$shift_info += 8;
} while ($size_info >= 0x80);
$shift_info += 7;
}
 
// TODO: Is this the packed or unpacked size? http://driusan.github.io/git-pack.html
if ($debug) echo "Packed size = ".sprintf('0x%x',$size)."\n";
 
// Read delta base type
if ($type == 6/*OBJ_OFS_DELTA*/) {
// "a negative relative offset from the delta object's position in the pack if this is an OBJ_OFS_DELTA object"
$delta_info = unpack('C*', fread($fp,4))[1];
if ($debug) echo "Delta negative offset: $delta_info\n";
 
// Offset encoding
$offset = 0;
$shift_info = 0;
do {
$offset_info = unpack('C', fread($fp,1))[1];
$offset = (($offset_info & 0x7F) << $shift_info) + $offset;
$shift_info += 7;
} while ($offset_info >= 0x80);
 
if ($debug) echo "Delta negative offset: $offset\n";
throw new Exception("OBJ_OFS_DELTA is currently not implemented"); // TODO! Implement OBJ_OFS_DELTA!
}
if ($type == 7/*OBJ_REF_DELTA*/) {
238,7 → 249,7
 
// Check CRC32
// TODO: Does not fit; neither crc32, nor crc32b...
// if ($debug) echo "CRC32 found = 0x".hash('crc32',$compressed)."\n";
// if ($debug) echo "CRC32 found = 0x".hash('crc32',$compressed)." vs $crc32\n";
 
return $uncompressed;
}