git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 25, 2015, 19:27 UTC
Message-ID
<xmqqvbho27ym.fsf@gitster.dls.corp.google.com>
In-Reply-To
<1427268105-16901-1-git-send-email-karthik.188@gmail.com>
Karthik Nayak <karthik.188@gmail.com> writes:
Show 26 quoted lines
> +static int unpack_sha1_header_to_strbuf(git_zstream *stream, unsigned char *map,
> +					unsigned long mapsize,
> +					struct strbuf *header)
> +{
> +	unsigned char buffer[32], *cp;
> +	unsigned long bufsiz = sizeof(buffer);
> +	int status;
> +
> +	status = unpack_sha1_header(stream, map, mapsize, buffer, bufsiz);
> +
> +	if (status) {
> +		strbuf_add(header, buffer, stream->next_out - buffer);
> +		return status;
> +	}
> +
> +	do {
> +		status = git_inflate(stream, 0);
> +		strbuf_add(header, buffer, stream->next_out - buffer);
> +		for (cp = buffer; cp < stream->next_out; cp++)
> +			if (!*cp)
> +				/* Found the NUL at the end of the header */
> +				return 0;
> +		stream->next_out = buffer;
> +		stream->avail_out = bufsiz;
> +	} while (status == Z_OK);
> +	return -1;

A caller of unpack_sha1_header() gets the return from git_inflate(); I wonder if we should be returning "status" here for consistency, perhaps?

Previous: Junio C HamanoNext: karthik nayak
Message 6 of 10 in “cat-file: add a '--literally' option”
  1. 0/2 cat-file: add a '--literally' optionkarthik nayak, Mar 25, 2015
  2. 1/2 sha1_file.c: support reading from a loose object of unknown typeKarthik Nayak, Mar 25, 2015
  3. Junio C HamanoMar 25, 2015
  4. karthik nayakMar 25, 2015
  5. Junio C HamanoMar 25, 2015
  6. Junio C HamanoMar 25, 2015
  7. karthik nayakMar 25, 2015
  8. 2/2 cat-file: teach cat-file a '--literally' optionKarthik Nayak, Mar 25, 2015
  9. Eric SunshineMar 25, 2015
  10. karthik nayakMar 25, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.