[PATCH v5 1/2] sha1_file.c: support reading from a loose object of unknown type

2015-03-25 Thread Karthik Nayak
Update sha1_loose_object_info() to optionally allow it to read from a loose object file of unknown/bogus type; as the function usually returns the type of the object it read in the form of enum for known types, add an optional typename field to receive the name of the type in textual form and a

Re: [PATCH v5 1/2] sha1_file.c: support reading from a loose object of unknown type

2015-03-25 Thread Junio C Hamano
Karthik Nayak karthik@gmail.com writes: + if ((flags LOOKUP_LITERALLY)) { + if (unpack_sha1_header_to_strbuf(stream, map, mapsize, hdrbuf) 0) + status = error(unable to unpack %s header with --literally, +

Re: [PATCH v5 1/2] sha1_file.c: support reading from a loose object of unknown type

2015-03-25 Thread Junio C Hamano
Karthik Nayak karthik@gmail.com writes: +static int unpack_sha1_header_to_strbuf(git_zstream *stream, unsigned char *map, + unsigned long mapsize, + struct strbuf *header) +{ + unsigned char buffer[32], *cp; +

Re: [PATCH v5 1/2] sha1_file.c: support reading from a loose object of unknown type

2015-03-25 Thread karthik nayak
On 03/26/2015 12:57 AM, Junio C Hamano wrote: Karthik Nayak karthik@gmail.com writes: +static int unpack_sha1_header_to_strbuf(git_zstream *stream, unsigned char *map, + unsigned long mapsize, + struct strbuf

Re: [PATCH v5 1/2] sha1_file.c: support reading from a loose object of unknown type

2015-03-25 Thread Junio C Hamano
karthik nayak karthik@gmail.com writes: I hope you meant the former. I did mean the latter, which spends more lines without much information (i.e. only closing braces), only to reduce the duplication of two simple lines. But you are right, I did miss the distinction between hdrbuf.buf and

Re: [PATCH v5 1/2] sha1_file.c: support reading from a loose object of unknown type

2015-03-25 Thread karthik nayak
On 03/26/2015 12:43 AM, Junio C Hamano wrote: Karthik Nayak karthik@gmail.com writes: + if ((flags LOOKUP_LITERALLY)) { + if (unpack_sha1_header_to_strbuf(stream, map, mapsize, hdrbuf) 0) + status = error(unable to unpack %s header with