Re: [PATCH 2/3] sha1_file: add the ability to parse objects in "pack file format"
- From
Junio C Hamano <junkio@cox.net>
- Date
- Jul 12, 2006, 07:16 UTC
- Message-ID
- <7vveq3z41v.fsf@assigned-by-dhcp.cox.net>
- In-Reply-To
- <slrneb96rd.dma.Peter.B.Baumann@xp.machine.xx>
Peter Baumann <Peter.B.Baumann@stud.informatik.uni-erlangen.de> writes:
Show 29 quoted lines
>> + bits = 4;
>> + size = c & 0xf;
>> + while (!(c & 0x80)) {
>> + if (bits >= 8*sizeof(long))
>> + return -1;
>> + c = *map++;
>> + size += (c & 0x7f) << bits;
>> + bits += 7;
>> + mapsize--;
>> + }
>
> This doesn't match the logic used in unpack_object_header, which is used
> in the packs:
> ...
>> + c = (type << 4) | (len & 15);
>> + len >>= 4;
>> + hdr_len = 1;
>> + while (len) {
>> + *hdr++ = c;
>> + hdr_len++;
>> + c = (len & 0x7f);
>> + len >>= 7;
>> + }
>> + *hdr = c | 0x80;
>> + return hdr_len;
>> +}
>> +
>
> Dito, but in this case see pack-objects.cWell, while these are not strictly needed to match, there is no good reason to make them inconsistent. Very well spotted.