Subject: Re: [PATCH v10 0/4] cat-file: add support for "-allow-unknown-type"

From: karthik nayak <[email-masked]>
Date: Mon, 04 May 2015 19:00:32 +0530

On 05/04/2015 05:44 AM, Junio C Hamano wrote:
> Junio C Hamano <[email-masked]> writes:
>
>> Hmmmm... you do not seem to pass your own test.
>>
>> expecting success:
>>          echo $bogus_type >expect &&
>>          git cat-file -t --allow-unknown-type $bogus_sha1 >actual &&
>>          test_cmp expect actual
>>
>> --- expect      2015-05-04 00:09:24.327335512 +0000
>> +++ actual      2015-05-04 00:09:24.335335473 +0000
>> @@ -1 +1 @@
>> -abcdefghijklmnopqrstuvwxyz1234679
>> +abcdefghijklmnopqrstuvwxyz123467abcdefghijklmnopqrstuvwxyz1234679
>> not ok 86 - Type of broken object is correct when type is large
>
> Perhaps it would have a better chance of being correct with this
> squashed in.
>
> -- >8 --
> [PATCH] fixup! sha1_file: support reading from a loose object of unknown type
>
> ---
>   sha1_file.c | 2 --
>   1 file changed, 2 deletions(-)
>
> diff --git a/sha1_file.c b/sha1_file.c
> index f65bf90..e010e7c 100644
> --- a/sha1_file.c
> +++ b/sha1_file.c
> @@ -1568,7 +1568,6 @@ static int unpack_sha1_header_to_strbuf(git_zstream *stream, unsigned char *map,
>   					unsigned long mapsize, void *buffer,
>   					unsigned long bufsiz, struct strbuf *header)
>   {
> -	unsigned char *cp;
>   	int status;
>
>   	status = unpack_sha1_header(stream, map, mapsize, buffer, bufsiz);
> @@ -1579,7 +1578,6 @@ static int unpack_sha1_header_to_strbuf(git_zstream *stream, unsigned char *map,
>   	if (memchr(buffer, '\0', stream->next_out - (unsigned char *)buffer))
>   		return 0;
>
> -	strbuf_add(header, buffer, stream->next_out - (unsigned char *)buffer);
Ok this works, weird, I test before sending patches, anyways getting to 
the point of discussion, shouldn't we have add the buf, since we did 
inflate once, before doing inflate again?
>   	do {
>   		status = git_inflate(stream, 0);
>   		strbuf_add(header, buffer, stream->next_out - (unsigned char *)buffer);
>